quantproject-developers Mailing List for QuantProject (Page 107)
Brought to you by:
glauco_1
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(7) |
Nov
(103) |
Dec
(67) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(52) |
Feb
(9) |
Mar
(69) |
Apr
(53) |
May
(80) |
Jun
(23) |
Jul
(24) |
Aug
(112) |
Sep
(9) |
Oct
|
Nov
(58) |
Dec
(93) |
| 2005 |
Jan
(90) |
Feb
(93) |
Mar
(61) |
Apr
(56) |
May
(37) |
Jun
(61) |
Jul
(55) |
Aug
(68) |
Sep
(25) |
Oct
(46) |
Nov
(41) |
Dec
(37) |
| 2006 |
Jan
(33) |
Feb
(7) |
Mar
(19) |
Apr
(27) |
May
(73) |
Jun
(49) |
Jul
(83) |
Aug
(66) |
Sep
(45) |
Oct
(16) |
Nov
(15) |
Dec
(7) |
| 2007 |
Jan
(14) |
Feb
(33) |
Mar
|
Apr
(21) |
May
|
Jun
(34) |
Jul
(18) |
Aug
(100) |
Sep
(39) |
Oct
(55) |
Nov
(12) |
Dec
(2) |
| 2008 |
Jan
(120) |
Feb
(133) |
Mar
(129) |
Apr
(104) |
May
(42) |
Jun
(2) |
Jul
(52) |
Aug
(99) |
Sep
(134) |
Oct
|
Nov
(137) |
Dec
(48) |
| 2009 |
Jan
(48) |
Feb
(55) |
Mar
(61) |
Apr
(3) |
May
(2) |
Jun
(1) |
Jul
|
Aug
(51) |
Sep
|
Oct
(7) |
Nov
|
Dec
|
| 2010 |
Jan
(7) |
Feb
(1) |
Mar
(145) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(8) |
Dec
|
| 2011 |
Jan
(78) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(88) |
Sep
(6) |
Oct
(1) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
(1) |
Mar
|
Apr
(6) |
May
(5) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2013 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Glauco S. <gla...@us...> - 2005-06-19 14:47:51
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9847/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows Modified Files: ReturnOnAccount.cs PercentageWinningPeriods.cs NumberWinningTrades.cs NumberWinningShortTrades.cs NumberWinningPeriods.cs NumberWinningLongTrades.cs NumberLosingPeriods.cs NumberEvenPeriods.cs MaxEquityDrawDown.cs LargestWinningTradePercentage.cs LargestLosingTradePercentage.cs Log Message: Reordered the process to populate the summary. Now, to add a summary item, you just need to add a new SummaryRow object to the QuantProject.Business.Financial.Accounting.Reporting.Tables.Summary object. Index: PercentageWinningPeriods.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows/PercentageWinningPeriods.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PercentageWinningPeriods.cs 17 Apr 2005 22:11:22 -0000 1.1 --- PercentageWinningPeriods.cs 19 Jun 2005 14:47:40 -0000 1.2 *************** *** 33,42 **** /// </summary> [Serializable] ! public class PercentageWinningPeriods : SummaryRow { public PercentageWinningPeriods( Summary summary ) { ! this.rowDescription = "# losing periods"; ! this.rowValue = summary.PercentageWinningPeriods; } } --- 33,44 ---- /// </summary> [Serializable] ! public class PercentageWinningPeriods : PercentageSummaryRow { public PercentageWinningPeriods( Summary summary ) { ! this.rowDescription = "% winning periods"; ! this.rowValue = (double)summary.NumberWinningPeriods.Value * 100/ ! ((double)summary.NumberWinningPeriods.Value + ! (double)summary.NumberLosingPeriods.Value); } } Index: MaxEquityDrawDown.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows/MaxEquityDrawDown.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MaxEquityDrawDown.cs 7 Jun 2005 15:06:21 -0000 1.3 --- MaxEquityDrawDown.cs 19 Jun 2005 14:47:40 -0000 1.4 *************** *** 9,13 **** /// </summary> [Serializable] ! public class MaxEquityDrawDown : SummaryRow { private Summary summary; --- 9,13 ---- /// </summary> [Serializable] ! public class MaxEquityDrawDown : PercentageSummaryRow { private Summary summary; Index: NumberWinningPeriods.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows/NumberWinningPeriods.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NumberWinningPeriods.cs 17 Apr 2005 23:15:15 -0000 1.2 --- NumberWinningPeriods.cs 19 Jun 2005 14:47:40 -0000 1.3 *************** *** 33,40 **** /// </summary> [Serializable] ! public class NumberWinningPeriods : SummaryRow { private Summary summary; private void setWinningLosingAndEvenPeriods_forPeriod( int i ) { --- 33,44 ---- /// </summary> [Serializable] ! public class NumberWinningPeriods : IntegerSummaryRow { private Summary summary; + private double numberWinningPeriods; + private double numberLosingPeriods; + private double numberEvenPeriods; + private void setWinningLosingAndEvenPeriods_forPeriod( int i ) { *************** *** 48,58 **** Convert.ToDouble( this.summary.AccountReport.BenchmarkEquityLine.GetByIndex( i ) ); if ( ( equityHistoryGain - benchmarkGain ) > ConstantsProvider.MinForDifferentGains ) ! this.summary.NumberWinningPeriods++; else { if ( ( benchmarkGain - equityHistoryGain ) > ConstantsProvider.MinForDifferentGains ) ! this.summary.NumberLosingPeriods++; else ! this.summary.NumberEvenPeriods++; } } --- 52,62 ---- Convert.ToDouble( this.summary.AccountReport.BenchmarkEquityLine.GetByIndex( i ) ); if ( ( equityHistoryGain - benchmarkGain ) > ConstantsProvider.MinForDifferentGains ) ! this.numberWinningPeriods++; else { if ( ( benchmarkGain - equityHistoryGain ) > ConstantsProvider.MinForDifferentGains ) ! this.numberLosingPeriods++; else ! this.numberEvenPeriods++; } } *************** *** 60,75 **** public void SetWinningLosingAndEvenPeriods() { ! this.summary.NumberWinningPeriods = 0; ! this.summary.NumberLosingPeriods = 0; ! this.summary.NumberEvenPeriods = 0; for ( int i=0; i<this.summary.AccountReport.EquityHistory.Count - 1 ; i++ ) this.setWinningLosingAndEvenPeriods_forPeriod( i ); } ! public NumberWinningPeriods( Summary summary ) { this.summary = summary; this.SetWinningLosingAndEvenPeriods(); this.rowDescription = "# winning periods"; ! this.rowValue = this.summary.NumberWinningPeriods; } } --- 64,84 ---- public void SetWinningLosingAndEvenPeriods() { ! this.numberWinningPeriods = 0; ! this.numberLosingPeriods = 0; ! this.numberEvenPeriods = 0; for ( int i=0; i<this.summary.AccountReport.EquityHistory.Count - 1 ; i++ ) this.setWinningLosingAndEvenPeriods_forPeriod( i ); } ! public NumberWinningPeriods( Summary summary ) : base() { this.summary = summary; this.SetWinningLosingAndEvenPeriods(); this.rowDescription = "# winning periods"; ! this.format = ConstantsProvider.FormatWithZeroDecimals; ! this.rowValue = this.numberWinningPeriods; ! } ! public double NumberLosingPeriods ! { ! get { return this.numberLosingPeriods; } } } Index: NumberWinningTrades.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows/NumberWinningTrades.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NumberWinningTrades.cs 19 Feb 2005 15:58:52 -0000 1.3 --- NumberWinningTrades.cs 19 Jun 2005 14:47:40 -0000 1.4 *************** *** 11,19 **** /// </summary> [Serializable] ! public class NumberWinningTrades : SummaryRow { public NumberWinningTrades( Summary summary ) { this.rowDescription = "Number winning trades"; try { --- 11,20 ---- /// </summary> [Serializable] ! public class NumberWinningTrades : IntegerSummaryRow { public NumberWinningTrades( Summary summary ) { this.rowDescription = "Number winning trades"; + this.format = ConstantsProvider.FormatWithZeroDecimals; try { Index: NumberEvenPeriods.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows/NumberEvenPeriods.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NumberEvenPeriods.cs 17 Apr 2005 22:11:22 -0000 1.1 --- NumberEvenPeriods.cs 19 Jun 2005 14:47:40 -0000 1.2 *************** *** 33,37 **** /// </summary> [Serializable] ! public class NumberEvenPeriods : SummaryRow { public NumberEvenPeriods( Summary summary ) --- 33,37 ---- /// </summary> [Serializable] ! public class NumberEvenPeriods : IntegerSummaryRow { public NumberEvenPeriods( Summary summary ) Index: NumberWinningLongTrades.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows/NumberWinningLongTrades.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NumberWinningLongTrades.cs 19 Feb 2005 15:58:52 -0000 1.3 --- NumberWinningLongTrades.cs 19 Jun 2005 14:47:40 -0000 1.4 *************** *** 11,19 **** /// </summary> [Serializable] ! public class NumberWinningLongTrades : SummaryRow { public NumberWinningLongTrades( Summary summary ) { this.rowDescription = "Number winning long trades"; try { --- 11,20 ---- /// </summary> [Serializable] ! public class NumberWinningLongTrades : IntegerSummaryRow { public NumberWinningLongTrades( Summary summary ) { this.rowDescription = "Number winning long trades"; + this.format = ConstantsProvider.FormatWithZeroDecimals; try { Index: NumberLosingPeriods.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows/NumberLosingPeriods.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NumberLosingPeriods.cs 17 Apr 2005 22:11:22 -0000 1.1 --- NumberLosingPeriods.cs 19 Jun 2005 14:47:40 -0000 1.2 *************** *** 33,42 **** /// </summary> [Serializable] ! public class NumberLosingPeriods : SummaryRow { ! public NumberLosingPeriods( Summary summary ) { this.rowDescription = "# losing periods"; ! this.rowValue = summary.NumberLosingPeriods; } } --- 33,43 ---- /// </summary> [Serializable] ! public class NumberLosingPeriods : IntegerSummaryRow { ! public NumberLosingPeriods( Summary summary ) : base() { this.rowDescription = "# losing periods"; ! this.format = ConstantsProvider.FormatWithZeroDecimals; ! this.rowValue = summary.NumberWinningPeriods.NumberLosingPeriods; } } Index: LargestLosingTradePercentage.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows/LargestLosingTradePercentage.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LargestLosingTradePercentage.cs 19 Feb 2005 16:02:15 -0000 1.3 --- LargestLosingTradePercentage.cs 19 Jun 2005 14:47:40 -0000 1.4 *************** *** 11,15 **** /// </summary> [Serializable] ! public class LargestLosingTradePercentage : SummaryRow { public LargestLosingTradePercentage( Summary summary ) --- 11,15 ---- /// </summary> [Serializable] ! public class LargestLosingTradePercentage : PercentageSummaryRow { public LargestLosingTradePercentage( Summary summary ) Index: LargestWinningTradePercentage.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows/LargestWinningTradePercentage.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LargestWinningTradePercentage.cs 19 Feb 2005 16:02:15 -0000 1.3 --- LargestWinningTradePercentage.cs 19 Jun 2005 14:47:40 -0000 1.4 *************** *** 11,15 **** /// </summary> [Serializable] ! public class LargestWinningTradePercentage : SummaryRow { public LargestWinningTradePercentage( Summary summary ) --- 11,15 ---- /// </summary> [Serializable] ! public class LargestWinningTradePercentage : PercentageSummaryRow { public LargestWinningTradePercentage( Summary summary ) Index: NumberWinningShortTrades.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows/NumberWinningShortTrades.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NumberWinningShortTrades.cs 19 Feb 2005 15:58:52 -0000 1.3 --- NumberWinningShortTrades.cs 19 Jun 2005 14:47:40 -0000 1.4 *************** *** 11,19 **** /// </summary> [Serializable] ! public class NumberWinningShortTrades : SummaryRow { public NumberWinningShortTrades( Summary summary ) { this.rowDescription = "Number winning short trades"; try { --- 11,20 ---- /// </summary> [Serializable] ! public class NumberWinningShortTrades : IntegerSummaryRow { public NumberWinningShortTrades( Summary summary ) { this.rowDescription = "Number winning short trades"; + this.format = ConstantsProvider.FormatWithZeroDecimals; try { Index: ReturnOnAccount.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows/ReturnOnAccount.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ReturnOnAccount.cs 15 Feb 2005 19:09:04 -0000 1.3 --- ReturnOnAccount.cs 19 Jun 2005 14:47:40 -0000 1.4 *************** *** 9,19 **** /// </summary> [Serializable] ! public class ReturnOnAccount : SummaryRow { public ReturnOnAccount( Summary summary ) { - summary.ReturnOnAccount = summary.TotalPnl / ( summary.FinalAccountValue - summary.TotalPnl ) * 100; this.rowDescription = "Return on account"; ! this.rowValue = summary.ReturnOnAccount; } } --- 9,18 ---- /// </summary> [Serializable] ! public class ReturnOnAccount : PercentageSummaryRow { public ReturnOnAccount( Summary summary ) { this.rowDescription = "Return on account"; ! this.rowValue = summary.TotalPnl / ( summary.FinalAccountValue - summary.TotalPnl ) * 100; } } |
|
From: Glauco S. <gla...@us...> - 2005-06-19 14:47:07
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9349/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables Modified Files: Summary.cs Log Message: Reordered the process to populate the summary. Now, to add a summary item, you just need to add a new SummaryRow object to the QuantProject.Business.Financial.Accounting.Reporting.Tables.Summary object. Index: Summary.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables/Summary.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Summary.cs 17 Apr 2005 23:05:02 -0000 1.15 --- Summary.cs 19 Jun 2005 14:46:59 -0000 1.16 *************** *** 18,24 **** private IHistoricalQuoteProvider historicalQuoteProvider; private double totalPnl; ! private double benchmarkPercentageReturn; private double finalAccountValue; private long intervalDays; private MaxEquityDrawDown maxEquityDrawDown; private TotalNumberOfTrades totalNumberOfTrades; --- 18,27 ---- private IHistoricalQuoteProvider historicalQuoteProvider; private double totalPnl; ! private BenchmarkPercentageReturn benchmarkPercentageReturn; ! private AnnualSystemPercentageReturn annualSystemPercentageReturn; private double finalAccountValue; private long intervalDays; + private TotalNetProfit totalNetProfit; + private ReturnOnAccount returnOnAccount; private MaxEquityDrawDown maxEquityDrawDown; private TotalNumberOfTrades totalNumberOfTrades; *************** *** 33,36 **** --- 36,42 ---- private TotalNumberOfShortTrades totalNumberOfShortTrades; private TotalCommissionAmount totalCommissionAmount; + private NumberWinningPeriods numberWinningPeriods; + private NumberLosingPeriods numberLosingPeriods; + private PercentageWinningPeriods percentageWinningPeriods; public AccountReport AccountReport { *************** *** 41,48 **** get { return totalPnl; } } ! public double BenchmarkPercentageReturn { get { return this.benchmarkPercentageReturn; } - set { this.benchmarkPercentageReturn = value; } } public double FinalAccountValue --- 47,61 ---- get { return totalPnl; } } ! public TotalNetProfit TotalNetProfit ! { ! get { return this.totalNetProfit; } ! } ! public ReturnOnAccount ReturnOnAccount ! { ! get { return this.returnOnAccount; } ! } ! public BenchmarkPercentageReturn BenchmarkPercentageReturn { get { return this.benchmarkPercentageReturn; } } public double FinalAccountValue *************** *** 54,118 **** get { return intervalDays; } } ! public double ReturnOnAccount; ! public double AnnualSystemPercentageReturn; ! public int NumberWinningPeriods; ! public int NumberLosingPeriods; public int NumberEvenPeriods; ! public double PercentageWinningPeriods { get { ! return this.NumberWinningPeriods*100/(this.NumberWinningPeriods+this.NumberLosingPeriods); } } ! public double MaxEquityDrawDown ! { ! get { return Convert.ToDouble( this.maxEquityDrawDown.Value ); } ! } ! public double TotalNumberOfTrades { ! get { return (int)this.totalNumberOfTrades.Value; } } ! public int NumberWinningTrades { ! get { return (int)this.numberWinningTrades.Value; } } ! public double AverageTradePercentageReturn { ! get { return Convert.ToDouble( this.averageTradePercentageReturn.Value ); } } ! public double LargestWinningTradePercentage { ! get { return Convert.ToDouble( this.largestWinningTradePercentage.Value ); } } ! public double LargestLosingTradePercentage { ! get { return Convert.ToDouble( this.largestLosingTradePercentage.Value ); } } ! public double NumberWinningLongTrades { ! get { return (int)this.numberWinningLongTrades.Value; } } ! public double AverageLongTradePercentageReturn { ! get { return Convert.ToDouble( this.averageLongTradePercentageReturn.Value ); } } ! public double NumberWinningShortTrades { ! get { return (int)this.numberWinningShortTrades.Value; } } ! public double TotalNumberOfLongTrades { ! get { return (int)this.totalNumberOfLongTrades.Value; } } ! public double TotalNumberOfShortTrades { ! get { return (int)this.totalNumberOfShortTrades.Value; } } - public double TotalCommissionAmount - { - get { return Convert.ToDouble( this.totalCommissionAmount.Value ); } - } --- 67,139 ---- get { return intervalDays; } } ! public AnnualSystemPercentageReturn AnnualSystemPercentageReturn ! { ! get { return this.annualSystemPercentageReturn; } ! } ! public MaxEquityDrawDown MaxEquityDrawDown ! { ! get { return this.maxEquityDrawDown; } ! } ! public TotalCommissionAmount TotalCommissionAmount ! { ! get { return this.totalCommissionAmount; } ! } ! public NumberWinningPeriods NumberWinningPeriods ! { ! get { return this.numberWinningPeriods; } ! } ! public NumberLosingPeriods NumberLosingPeriods ! { ! get { return this.numberLosingPeriods; } ! } public int NumberEvenPeriods; ! public PercentageWinningPeriods PercentageWinningPeriods { get { ! return this.percentageWinningPeriods; } } ! public TotalNumberOfTrades TotalNumberOfTrades { ! get { return this.totalNumberOfTrades; } } ! public NumberWinningTrades NumberWinningTrades { ! get { return this.numberWinningTrades; } } ! public AverageTradePercentageReturn AverageTradePercentageReturn { ! get { return this.averageTradePercentageReturn; } } ! public LargestWinningTradePercentage LargestWinningTradePercentage { ! get { return this.largestWinningTradePercentage; } } ! public LargestLosingTradePercentage LargestLosingTradePercentage { ! get { return this.largestLosingTradePercentage; } } ! public TotalNumberOfLongTrades TotalNumberOfLongTrades { ! get { return this.totalNumberOfLongTrades; } } ! public NumberWinningLongTrades NumberWinningLongTrades { ! get { return this.numberWinningLongTrades; } } ! public AverageLongTradePercentageReturn AverageLongTradePercentageReturn { ! get { return this.averageLongTradePercentageReturn; } } ! public TotalNumberOfShortTrades TotalNumberOfShortTrades { ! get { return this.totalNumberOfShortTrades; } } ! public NumberWinningShortTrades NumberWinningShortTrades { ! get { return this.numberWinningShortTrades; } } *************** *** 120,123 **** --- 141,146 ---- { this.accountReport = accountReport; + this.numberWinningPeriods = new NumberWinningPeriods( this ); + this.numberLosingPeriods = new NumberLosingPeriods( this ); this.getSummary(); } *************** *** 154,166 **** { getSummary_setRow( new TotalNetProfit( this ) , summaryDataTable ); ! getSummary_setRow( new ReturnOnAccount( this ) , summaryDataTable ); ! getSummary_setRow( new BenchmarkPercentageReturn( this , this.historicalQuoteProvider ) , summaryDataTable ); ! getSummary_setRow( new NumberWinningPeriods( this ) , summaryDataTable ); ! getSummary_setRow( new NumberLosingPeriods( this ) , summaryDataTable ); getSummary_setRow( new NumberEvenPeriods( this ) , summaryDataTable ); ! getSummary_setRow( new PercentageWinningPeriods( this ) , summaryDataTable ); //this.getSummary_setRows_forEquityVsBenchmarkComparison(); ! getSummary_setRow( new AnnualSystemPercentageReturn( this ) , summaryDataTable ); this.maxEquityDrawDown = new MaxEquityDrawDown( this ); getSummary_setRow( this.maxEquityDrawDown , summaryDataTable ); --- 177,197 ---- { getSummary_setRow( new TotalNetProfit( this ) , summaryDataTable ); ! this.returnOnAccount = new ReturnOnAccount( this ); ! getSummary_setRow( this.returnOnAccount , summaryDataTable ); ! this.benchmarkPercentageReturn = ! new BenchmarkPercentageReturn( this , this.historicalQuoteProvider ); ! getSummary_setRow( this.benchmarkPercentageReturn , summaryDataTable ); ! this.numberWinningPeriods = new NumberWinningPeriods( this ); ! getSummary_setRow( this.numberWinningPeriods , summaryDataTable ); ! this.numberLosingPeriods = new NumberLosingPeriods( this ); ! getSummary_setRow( this.numberLosingPeriods , summaryDataTable ); getSummary_setRow( new NumberEvenPeriods( this ) , summaryDataTable ); ! this.percentageWinningPeriods = new PercentageWinningPeriods( this ); ! getSummary_setRow( this.percentageWinningPeriods , summaryDataTable ); //this.getSummary_setRows_forEquityVsBenchmarkComparison(); ! this.totalNetProfit = new TotalNetProfit( this ); ! this.annualSystemPercentageReturn = new AnnualSystemPercentageReturn( this ); ! getSummary_setRow( this.annualSystemPercentageReturn , summaryDataTable ); this.maxEquityDrawDown = new MaxEquityDrawDown( this ); getSummary_setRow( this.maxEquityDrawDown , summaryDataTable ); |
|
From: Glauco S. <gla...@us...> - 2005-06-19 14:46:22
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8866/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows Modified Files: SummaryRow.cs Log Message: no message Index: SummaryRow.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows/SummaryRow.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SummaryRow.cs 20 Mar 2005 18:30:58 -0000 1.3 --- SummaryRow.cs 19 Jun 2005 14:46:07 -0000 1.4 *************** *** 11,14 **** --- 11,15 ---- internal string rowDescription; internal object rowValue; + internal string format; public string Description *************** *** 28,39 **** return returnValue; } ! set { rowValue = value; } } public SummaryRow() { ! // ! // TODO: Add constructor logic here ! // } } --- 29,50 ---- return returnValue; } ! set { this.rowValue = value; } } + public string FormattedValue + { + get + { + string returnValue = ""; + if ( this.format == "" ) + throw new Exception( "No format has been defined!" ); + if ( this.rowValue != null ) + returnValue = string.Format( "{0:" + this.format + "}" , this.Value ); + return returnValue; + } + } public SummaryRow() { ! this.format = ""; } } |
|
From: Glauco S. <gla...@us...> - 2005-06-19 14:45:52
|
Update of /cvsroot/quantproject/QuantProject/b5_Presentation/Reporting/WindowsForm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8675/b5_Presentation/Reporting/WindowsForm Modified Files: SummaryTabPage.cs Log Message: Reordered the process to populate the summary. Now, to add a summary item, you just need to add a new SummaryRow object to the QuantProject.Business.Financial.Accounting.Reporting.Tables.Summary object. Index: SummaryTabPage.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b5_Presentation/Reporting/WindowsForm/SummaryTabPage.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SummaryTabPage.cs 17 Apr 2005 23:05:02 -0000 1.5 --- SummaryTabPage.cs 19 Jun 2005 14:45:43 -0000 1.6 *************** *** 21,28 **** --- 21,31 ---- */ using System; + using System.Collections; using System.Drawing; + using System.Reflection; using System.Windows.Forms; using QuantProject.ADT; using QuantProject.Business.Financial.Accounting.Reporting; + using QuantProject.Business.Financial.Accounting.Reporting.SummaryRows; using QuantProject.Presentation; *************** *** 44,47 **** --- 47,56 ---- private int yStep = 25; + private ArrayList summaryItems; + /// <summary> + /// used just to apply the GetType method + /// </summary> + private SummaryRow summaryRow; + private System.Windows.Forms.Label lblValTotalNetProfit; private System.Windows.Forms.Label lblTotalNetProfit; *************** *** 123,126 **** --- 132,152 ---- } + private void addTextLabel( Label label ) + { + this.Controls.Add( label ); + // label.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + label.Location = getPointForTextLabel( ( this.Controls.Count - 1 ) / 2 ); + label.Width = this.textLabelsWidth; + label.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + } + private void addValueLabel( Label label ) + { + this.Controls.Add( label ); + // label.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + label.Location = getPointForValueLabel( ( this.Controls.Count / 2 ) - 1 ); + label.Width = this.valueLablesWidth; + label.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + } + private Point getPointForValueLabel( int labelPosition ) { *************** *** 129,134 **** return point; } ! private void myInitializeComponent() { this.lblTotalNetProfit = new System.Windows.Forms.Label(); this.lblValTotalNetProfit = new System.Windows.Forms.Label(); --- 155,185 ---- return point; } ! private void myInitializeComponent_addItem( SummaryItem summaryItem ) { + this.addTextLabel( summaryItem.Description ); + this.addValueLabel( summaryItem.Value ); + } + private void myInitializeComponent_addSummaryRow( PropertyInfo propertyInfo ) + { + Object ob = propertyInfo.GetValue( this.accountReport.Summary , null ); + if ( ob is SummaryRow ) + { + this.summaryItems.Add( new SummaryItem( + (SummaryRow)ob ) ); + } + } + private void myInitializeComponent_addSummaryRows() + { + foreach ( PropertyInfo summaryProperty in + this.accountReport.Summary.GetType().GetProperties() ) + myInitializeComponent_addSummaryRow( summaryProperty ); + } + private void myInitializeComponent_old() + { + this.summaryItems = new ArrayList(); + myInitializeComponent_addSummaryRows(); + foreach( SummaryItem summaryItem in this.summaryItems ) + this.myInitializeComponent_addItem( summaryItem ); + this.lblTotalNetProfit = new System.Windows.Forms.Label(); this.lblValTotalNetProfit = new System.Windows.Forms.Label(); *************** *** 344,347 **** --- 395,406 ---- } + private void myInitializeComponent() + { + this.summaryItems = new ArrayList(); + myInitializeComponent_addSummaryRows(); + foreach( SummaryItem summaryItem in this.summaryItems ) + this.myInitializeComponent_addItem( summaryItem ); + } + private void setSummaryValues() { *************** *** 349,361 **** FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.TotalPnl ); this.lblValReturnOnAccount.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.ReturnOnAccount ); this.lblValBenchmarkPercReturn.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.BenchmarkPercentageReturn ); this.lblValAnnualSystemPercReturn.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.AnnualSystemPercentageReturn ); ! this.lblValMaxEquityDrawDown.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.MaxEquityDrawDown ); this.lblValTotalCommission.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.TotalCommissionAmount ); this.lblValNumberWinningPeriods.Text = this.accountReport.Summary.NumberWinningPeriods.ToString(); --- 408,420 ---- FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.TotalPnl ); this.lblValReturnOnAccount.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( (double)this.accountReport.Summary.ReturnOnAccount.Value ); this.lblValBenchmarkPercReturn.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( (double)this.accountReport.Summary.BenchmarkPercentageReturn.Value ); this.lblValAnnualSystemPercReturn.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( (double)this.accountReport.Summary.AnnualSystemPercentageReturn.Value ); ! // this.lblValMaxEquityDrawDown.Text = ! // FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.MaxEquityDrawDown ); this.lblValTotalCommission.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( (double)this.accountReport.Summary.TotalCommissionAmount.Value ); this.lblValNumberWinningPeriods.Text = this.accountReport.Summary.NumberWinningPeriods.ToString(); *************** *** 363,394 **** this.accountReport.Summary.NumberLosingPeriods.ToString(); this.lblValPercentageWinningPeriods.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.PercentageWinningPeriods ); ! this.lblValTotalNumberOfTrades.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.TotalNumberOfTrades ); ! this.lblValNumberWinningTrades.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.NumberWinningTrades ); ! this.lblValAverageTradePercReturn.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.AverageTradePercentageReturn ); ! this.lblValLargestWinningTrade.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.LargestWinningTradePercentage ); ! this.lblValLargestLosingTrade.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.LargestLosingTradePercentage ); ! this.lblValTotalNumberOfLongTrades.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.TotalNumberOfLongTrades ); ! this.lblValNumberWinningLongTrades.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.NumberWinningLongTrades ); ! this.lblValAverageLongTradePercReturn.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.AverageLongTradePercentageReturn ); ! this.lblValTotalNumberOfShortTrades.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.TotalNumberOfShortTrades ); ! this.lblValNumberWinningShortTrades.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.NumberWinningShortTrades ); } public SummaryTabPage( AccountReport accountReport ) { this.accountReport = accountReport; this.myInitializeComponent(); this.Text = "Summary"; ! this.setSummaryValues(); } } --- 422,454 ---- this.accountReport.Summary.NumberLosingPeriods.ToString(); this.lblValPercentageWinningPeriods.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( (double)this.accountReport.Summary.PercentageWinningPeriods.Value ); ! // this.lblValTotalNumberOfTrades.Text = ! // FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.TotalNumberOfTrades ); ! // this.lblValNumberWinningTrades.Text = ! // FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.NumberWinningTrades ); ! // this.lblValAverageTradePercReturn.Text = ! // FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.AverageTradePercentageReturn ); ! // this.lblValLargestWinningTrade.Text = ! // FormatProvider.ConvertToStringWithTwoDecimals( (double)this.accountReport.Summary.LargestWinningTradePercentage.Value ); ! // this.lblValLargestLosingTrade.Text = ! // FormatProvider.ConvertToStringWithTwoDecimals( (double)this.accountReport.Summary.LargestLosingTradePercentage.Value ); ! // this.lblValTotalNumberOfLongTrades.Text = ! // FormatProvider.ConvertToStringWithZeroDecimals( (int)this.accountReport.Summary.TotalNumberOfLongTrades.Value ); ! // this.lblValNumberWinningLongTrades.Text = ! // FormatProvider.ConvertToStringWithTwoDecimals( (double)this.accountReport.Summary.NumberWinningLongTrades.Value ); ! // this.lblValAverageLongTradePercReturn.Text = ! // FormatProvider.ConvertToStringWithTwoDecimals( (double)this.accountReport.Summary.AverageLongTradePercentageReturn.Value ); ! // this.lblValTotalNumberOfShortTrades.Text = ! // FormatProvider.ConvertToStringWithTwoDecimals( (double)this.accountReport.Summary.TotalNumberOfShortTrades.Value ); ! // this.lblValNumberWinningShortTrades.Text = ! // FormatProvider.ConvertToStringWithTwoDecimals( (double)this.accountReport.Summary.NumberWinningShortTrades.Value ); } public SummaryTabPage( AccountReport accountReport ) { this.accountReport = accountReport; + this.summaryRow = new SummaryRow(); this.myInitializeComponent(); this.Text = "Summary"; ! // this.setSummaryValues(); } } |
|
From: Glauco S. <gla...@us...> - 2005-06-19 14:43:40
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7415/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows Modified Files: TotalCommissionAmount.cs Log Message: Reordered the process to populate the summary. Now, to add a summary item, you just need to add a new SummaryRow object to the QuantProject.Business.Financial.Accounting.Reporting.Tables.Summary object. Index: TotalCommissionAmount.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows/TotalCommissionAmount.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TotalCommissionAmount.cs 15 Feb 2005 19:09:04 -0000 1.2 --- TotalCommissionAmount.cs 19 Jun 2005 14:43:31 -0000 1.3 *************** *** 12,18 **** /// </summary> [Serializable] ! public class TotalCommissionAmount : SummaryRow { ! public TotalCommissionAmount( Summary summary ) { this.rowDescription = "Total commission amount"; --- 12,18 ---- /// </summary> [Serializable] ! public class TotalCommissionAmount : DoubleSummaryRow { ! public TotalCommissionAmount( Summary summary ) : base( 2 ) { this.rowDescription = "Total commission amount"; |
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6711/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows Modified Files: TotalNumberOfTrades.cs TotalNumberOfShortTrades.cs TotalNumberOfLongTrades.cs TotalNetProfit.cs Log Message: Reordered the process to populate the summary. Now, to add a summary item, you just need to add a new SummaryRow object to the QuantProject.Business.Financial.Accounting.Reporting.Tables.Summary object. Index: TotalNetProfit.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows/TotalNetProfit.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TotalNetProfit.cs 15 Feb 2005 19:09:04 -0000 1.2 --- TotalNetProfit.cs 19 Jun 2005 14:42:23 -0000 1.3 *************** *** 9,15 **** /// </summary> [Serializable] ! public class TotalNetProfit : SummaryRow { ! public TotalNetProfit( Summary summary ) { this.rowDescription = "Total net profit"; --- 9,15 ---- /// </summary> [Serializable] ! public class TotalNetProfit : DoubleSummaryRow { ! public TotalNetProfit( Summary summary ) : base( 2 ) { this.rowDescription = "Total net profit"; Index: TotalNumberOfShortTrades.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows/TotalNumberOfShortTrades.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TotalNumberOfShortTrades.cs 19 Feb 2005 15:58:52 -0000 1.3 --- TotalNumberOfShortTrades.cs 19 Jun 2005 14:42:23 -0000 1.4 *************** *** 11,15 **** /// </summary> [Serializable] ! public class TotalNumberOfShortTrades : SummaryRow { public TotalNumberOfShortTrades( Summary summary ) --- 11,15 ---- /// </summary> [Serializable] ! public class TotalNumberOfShortTrades : IntegerSummaryRow { public TotalNumberOfShortTrades( Summary summary ) Index: TotalNumberOfLongTrades.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows/TotalNumberOfLongTrades.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TotalNumberOfLongTrades.cs 19 Feb 2005 15:58:52 -0000 1.3 --- TotalNumberOfLongTrades.cs 19 Jun 2005 14:42:23 -0000 1.4 *************** *** 11,17 **** /// </summary> [Serializable] ! public class TotalNumberOfLongTrades : SummaryRow { ! public TotalNumberOfLongTrades( Summary summary ) { double totalROA = summary.TotalPnl / ( summary.FinalAccountValue - summary.TotalPnl ); --- 11,17 ---- /// </summary> [Serializable] ! public class TotalNumberOfLongTrades : IntegerSummaryRow { ! public TotalNumberOfLongTrades( Summary summary ) : base() { double totalROA = summary.TotalPnl / ( summary.FinalAccountValue - summary.TotalPnl ); Index: TotalNumberOfTrades.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows/TotalNumberOfTrades.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TotalNumberOfTrades.cs 19 Feb 2005 16:02:15 -0000 1.3 --- TotalNumberOfTrades.cs 19 Jun 2005 14:42:23 -0000 1.4 *************** *** 1,4 **** --- 1,6 ---- using System; using System.Data; + + using QuantProject.ADT; using QuantProject.Business.Financial.Accounting.Reporting.Tables; *************** *** 9,13 **** /// </summary> [Serializable] ! public class TotalNumberOfTrades : SummaryRow { public TotalNumberOfTrades( Summary summary ) --- 11,15 ---- /// </summary> [Serializable] ! public class TotalNumberOfTrades : IntegerSummaryRow { public TotalNumberOfTrades( Summary summary ) *************** *** 15,18 **** --- 17,21 ---- double totalROA = summary.TotalPnl / ( summary.FinalAccountValue - summary.TotalPnl ); this.rowDescription = "Total # of trades"; + this.format = ConstantsProvider.FormatWithZeroDecimals; try { |
|
From: Marco M. <mi...@us...> - 2005-06-10 18:57:24
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataTables In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25498/b3_Data/DataTables Modified Files: Tickers_tickerGroups.cs Log Message: Added constructor with no parameters, for calling correctly Clone method through the DataTable class. Index: Tickers_tickerGroups.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataTables/Tickers_tickerGroups.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Tickers_tickerGroups.cs 5 Sep 2004 13:48:16 -0000 1.1 --- Tickers_tickerGroups.cs 10 Jun 2005 18:57:06 -0000 1.2 *************** *** 38,42 **** public static string GroupID = "ttTgId"; public static string Ticker = "ttTiId"; ! public Tickers_tickerGroups(string groupID) { --- 38,47 ---- public static string GroupID = "ttTgId"; public static string Ticker = "ttTiId"; ! ! public Tickers_tickerGroups() ! { ! ! } ! public Tickers_tickerGroups(string groupID) { |
|
From: Marco M. <mi...@us...> - 2005-06-10 18:52:15
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23020/b1_ADT Modified Files: ExtendedDataTable.cs Log Message: Modified CopyAndSort static method in ExtendedDataTable class Index: ExtendedDataTable.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/ExtendedDataTable.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ExtendedDataTable.cs 1 Dec 2004 22:46:59 -0000 1.8 --- ExtendedDataTable.cs 10 Jun 2005 18:52:00 -0000 1.9 *************** *** 38,50 **** /// <summary> ! /// Copy the given DataTable into another DataTable, sorting by the specified field, in a DESC mode /// </summary> public static DataTable CopyAndSort(DataTable tableToCopyAndSort, string sortingFieldName, bool sortByASC) { DataTable copyOfTableToCopyAndSort = tableToCopyAndSort.Clone(); string sortDirection = " DESC"; if(sortByASC) ! sortDirection = " ASC"; ! DataRow[] orderedRows = tableToCopyAndSort.Select("", sortingFieldName + sortDirection); for(int i = 0;i<orderedRows.Length;i++) { --- 38,63 ---- /// <summary> ! /// Copy the given DataTable into another DataTable, sorting by the specified field, in the given mode /// </summary> public static DataTable CopyAndSort(DataTable tableToCopyAndSort, string sortingFieldName, bool sortByASC) { + return ExtendedDataTable.CopyAndSort(tableToCopyAndSort, + "", sortingFieldName, sortByASC); + } + + /// <summary> + /// Copy the given DataTable into another DataTable, + /// filtering by the given expression, sorting by the specified field, in the given mode + /// </summary> + public static DataTable CopyAndSort(DataTable tableToCopyAndSort, + string filterExpression, + string sortingFieldName, bool sortByASC) + { DataTable copyOfTableToCopyAndSort = tableToCopyAndSort.Clone(); string sortDirection = " DESC"; if(sortByASC) ! sortDirection = " ASC"; ! ! DataRow[] orderedRows = tableToCopyAndSort.Select(filterExpression, sortingFieldName + sortDirection); for(int i = 0;i<orderedRows.Length;i++) { *************** *** 53,57 **** return copyOfTableToCopyAndSort; } ! public static void DeleteRows(DataTable table, long fromIndex) { --- 66,70 ---- return copyOfTableToCopyAndSort; } ! public static void DeleteRows(DataTable table, long fromIndex) { |
|
From: Marco M. <mi...@us...> - 2005-06-10 18:48:58
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21005/b1_ADT/Optimizing/Genetic Modified Files: Genome.cs GenomeManagement.cs GenomeManagerTest.cs Log Message: Fixed bug in MixGenesWithoutDuplicates method in GenomeManagement class. Index: GenomeManagerTest.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/GenomeManagerTest.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GenomeManagerTest.cs 1 Dec 2004 22:36:11 -0000 1.1 --- GenomeManagerTest.cs 10 Jun 2005 18:48:45 -0000 1.2 *************** *** 72,75 **** --- 72,76 ---- //return GenomeManagement.AlternateFixedCrossover(parent1, parent2); return GenomeManagement.OnePointCrossover(parent1, parent2); + //return GenomeManagement.MixGenesWithoutDuplicates(parent1, parent2); } Index: Genome.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/Genome.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Genome.cs 17 May 2005 23:03:36 -0000 1.2 --- Genome.cs 10 Jun 2005 18:48:44 -0000 1.3 *************** *** 109,118 **** } public Genome Clone() { Genome returnValue = new Genome(this.genomeManager); returnValue.Fitness = this.Fitness; returnValue.Meaning = this.Meaning; - returnValue.CopyValuesInGenes(this.genes); return returnValue; --- 109,122 ---- } + + /// <summary> + /// It creates an new genome, identical to the current instance + /// </summary> public Genome Clone() { Genome returnValue = new Genome(this.genomeManager); + returnValue.CopyValuesInGenes(this.genes); returnValue.Fitness = this.Fitness; returnValue.Meaning = this.Meaning; return returnValue; Index: GenomeManagement.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/GenomeManagement.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GenomeManagement.cs 1 Dec 2004 22:36:11 -0000 1.1 --- GenomeManagement.cs 10 Jun 2005 18:48:44 -0000 1.2 *************** *** 35,60 **** { ! public static Random RandomGenerator = new Random((int)DateTime.Now.Ticks); private static int genomeSize; private static Genome[] childs; private static int[,] maskForChilds; ! /* ! public GenomeManagement() { ! } ! */ /// <summary> ! /// Returns an array of genome (childs) based /// on classical one point crossover genes recombination /// </summary> public static Genome[] OnePointCrossover(Genome parent1, Genome parent2) { ! if(parent1.Size != parent2.Size) throw new Exception("Genomes must have the same size!"); ! GenomeManagement.genomeSize = parent1.Size; ! GenomeManagement.childs = new Genome[2]{parent1.Clone(),parent1.Clone()}; ! ! int pos = GenomeManagement.RandomGenerator.Next(0, parent1.Size); for(int i = 0 ; i < parent1.Size ; i++) { --- 35,76 ---- { ! public static Random RandomGenerator; private static int genomeSize; private static Genome[] childs; private static int[,] maskForChilds; ! ! static GenomeManagement() { ! RandomGenerator = new Random((int)DateTime.Now.Ticks); ! childs = new Genome[2]; } ! ! private static void initializeStaticMembers(Genome parent1, Genome parent2) ! { ! genomeSize = parent1.Size; ! childs[0] = parent1.Clone(); ! childs[1] = parent2.Clone(); ! //the two childs now points to their parents ! maskForChilds = new int[childs.Length, genomeSize]; ! } ! ! private static void assignFitnessAndMeaningToChilds() ! { ! foreach(Genome child in childs) ! { ! child.AssignMeaning(); ! child.CalculateFitness(); ! } ! } /// <summary> ! /// Returns an array of genome (length = 2) based /// on classical one point crossover genes recombination /// </summary> public static Genome[] OnePointCrossover(Genome parent1, Genome parent2) { ! GenomeManagement.initializeStaticMembers(parent1, parent2); ! if(parent1.Size != parent2.Size) throw new Exception("Genomes must have the same size!"); ! int pos = GenomeManagement.RandomGenerator.Next(0, parent1.Size); for(int i = 0 ; i < parent1.Size ; i++) { *************** *** 70,81 **** } } ! return GenomeManagement.childs; } private static void setMaskForChildsForUniformCrossover() { ! for(int childIndex = 0 ; ! childIndex < GenomeManagement.childs.Length; ! childIndex++) { for(int i = 0 ; i < GenomeManagement.genomeSize ; i++) --- 86,96 ---- } } ! GenomeManagement.assignFitnessAndMeaningToChilds(); ! return GenomeManagement.childs; } private static void setMaskForChildsForUniformCrossover() { ! for(int childIndex = 0; childIndex < 2; childIndex++) { for(int i = 0 ; i < GenomeManagement.genomeSize ; i++) *************** *** 88,145 **** private static void setMaskForChildsForAlternateFixedCrossover() { ! for(int childIndex = 0 ; ! childIndex < GenomeManagement.childs.Length; ! childIndex++) { ! for(int i = 0 ; i < GenomeManagement.genomeSize ; i++) { ! if(i%2 == 0) ! //index is even ! maskForChilds[childIndex, i] = 1; else ! // index is odd ! maskForChilds[childIndex, i] = 2; } } } ! ! private static void setMaskForChildsForMixingWithoutDuplicates(Genome parent1, Genome parent2) { ! for(int childIndex = 0 ; ! childIndex < GenomeManagement.childs.Length; ! childIndex++) { ! for(int i = 0 ; i < GenomeManagement.genomeSize ; i++) ! { ! if(parent2.HasGene(parent1.GetGeneValue(i)) || ! parent1.HasGene(parent2.GetGeneValue(i)))//index contains a common gene ! { ! maskForChilds[childIndex, i] = childIndex + 1; ! } ! else// index doesn't contain a common gene ! { ! if(i%2 == 0)//index is even ! maskForChilds[childIndex, i] = childIndex%2 + 1; ! else// index is odd ! maskForChilds[childIndex, i] = childIndex%2 + 2; ! } ! } } } - //it assumes just two parents only private static void setChildsUsingMaskForChilds(Genome parent1, Genome parent2) { ! for(int childIndex = 0 ; ! childIndex < GenomeManagement.childs.Length; ! childIndex++) { ! for(int i = 0 ; i < GenomeManagement.genomeSize ; i++) { ! if(maskForChilds[childIndex,i]==1) ! childs[childIndex].SetGeneValue(parent1.GetGeneValue(i), i); ! else//maskForChilds[childIndex,i]==2 ! childs[childIndex].SetGeneValue(parent2.GetGeneValue(i), i); } } --- 103,173 ---- private static void setMaskForChildsForAlternateFixedCrossover() { ! for(int childIndex = 0; childIndex < 2; childIndex++) { ! for(int genePos = 0; genePos < genomeSize; genePos++) { ! if(genePos%2 == 0) ! //gene position is even ! maskForChilds[childIndex, genePos] = 1; else ! // gene position is odd ! maskForChilds[childIndex, genePos] = 2; } } } ! ! private static int firstGenePositionOfParent1NotPresentInParent2(Genome parent1, ! Genome parent2) ! { ! int returnValue = -1; ! for(int genePos = 0 ; ! genePos < GenomeManagement.genomeSize && returnValue == -1; ! genePos++) ! { ! if(!parent2.HasGene(parent1.GetGeneValue(genePos))) ! returnValue = genePos; ! } ! return returnValue; ! } ! ! private static bool setMaskForChildsForMixingWithoutDuplicates(Genome parent1, Genome parent2) { ! bool returnValue = false; ! int firstGenePosOfParent1NotPresentInParent2 = ! firstGenePositionOfParent1NotPresentInParent2(parent1, parent2); ! int firstGenePosOfParent2NotPresentInParent1 = ! firstGenePositionOfParent1NotPresentInParent2(parent2, parent1); ! if(firstGenePosOfParent1NotPresentInParent2 > -1 && ! firstGenePosOfParent2NotPresentInParent1 > -1 ) ! //there is at least a gene in parent1 not present in parent2 and viceversa { ! for(int genePos = 0 ; genePos < GenomeManagement.genomeSize ; genePos++) ! { ! if(genePos == firstGenePosOfParent1NotPresentInParent2) ! maskForChilds[0, genePos] = 1; ! else ! maskForChilds[0, genePos] = 2; ! ! if(genePos == firstGenePosOfParent2NotPresentInParent1) ! maskForChilds[1, genePos] = 2; ! else ! maskForChilds[1, genePos] = 1; ! } ! returnValue = true; } + return returnValue; } private static void setChildsUsingMaskForChilds(Genome parent1, Genome parent2) { ! for(int childIndex = 0; childIndex < 2; childIndex++) { ! for(int genePos = 0 ; genePos < GenomeManagement.genomeSize ; genePos++) { ! if(maskForChilds[childIndex,genePos]==1) ! childs[childIndex].SetGeneValue(parent1.GetGeneValue(genePos), genePos); ! else//maskForChilds[childIndex,genePos]==2 ! childs[childIndex].SetGeneValue(parent2.GetGeneValue(genePos), genePos); } } *************** *** 153,166 **** public static Genome[] UniformCrossover(Genome parent1, Genome parent2) { if(parent1.Size != parent2.Size) throw new Exception("Genomes must have the same size!"); ! GenomeManagement.genomeSize = parent1.Size; ! GenomeManagement.childs = ! new Genome[2]{parent1.Clone(),parent1.Clone()}; ! GenomeManagement.maskForChilds = new int[childs.Length, GenomeManagement.genomeSize]; ! GenomeManagement.setMaskForChildsForUniformCrossover(); ! GenomeManagement.setChildsUsingMaskForChilds(parent1, parent2); ! return GenomeManagement.childs; } --- 181,191 ---- public static Genome[] UniformCrossover(Genome parent1, Genome parent2) { + initializeStaticMembers(parent1, parent2); if(parent1.Size != parent2.Size) throw new Exception("Genomes must have the same size!"); ! setMaskForChildsForUniformCrossover(); ! setChildsUsingMaskForChilds(parent1, parent2); ! return childs; } *************** *** 171,189 **** public static Genome[] AlternateFixedCrossover(Genome parent1, Genome parent2) { if(parent1.Size != parent2.Size) throw new Exception("Genomes must have the same size!"); ! GenomeManagement.genomeSize = parent1.Size; ! GenomeManagement.childs = ! new Genome[2]{parent1.Clone(),parent1.Clone()}; ! GenomeManagement.maskForChilds = new int[childs.Length, GenomeManagement.genomeSize]; ! GenomeManagement.setMaskForChildsForAlternateFixedCrossover(); ! GenomeManagement.setChildsUsingMaskForChilds(parent1, parent2); ! return GenomeManagement.childs; } /// <summary> /// This method returns an array of genomes based on ! /// a mix of the genes of parents, such that childs, /// if possible, are different from parents and, at /// the same time, childs' genes are not duplicated --- 196,211 ---- public static Genome[] AlternateFixedCrossover(Genome parent1, Genome parent2) { + initializeStaticMembers(parent1, parent2); if(parent1.Size != parent2.Size) throw new Exception("Genomes must have the same size!"); ! setMaskForChildsForAlternateFixedCrossover(); ! setChildsUsingMaskForChilds(parent1, parent2); ! return childs; } /// <summary> /// This method returns an array of genomes based on ! /// a mix of the genes of parents, such that the 2 childs, /// if possible, are different from parents and, at /// the same time, childs' genes are not duplicated *************** *** 191,194 **** --- 213,217 ---- public static Genome[] MixGenesWithoutDuplicates(Genome parent1, Genome parent2) { + initializeStaticMembers(parent1, parent2); if(parent1.Size > (parent1.MaxValueForGenes - parent1.MinValueForGenes + 1)) //it is impossible not to duplicate genes if size is too *************** *** 197,208 **** if(parent1.Size != parent2.Size) throw new Exception("Genomes must have the same size!"); - GenomeManagement.genomeSize = parent1.Size; - GenomeManagement.childs = - new Genome[2]{parent1.Clone(),parent1.Clone()}; - GenomeManagement.maskForChilds = new int[childs.Length, GenomeManagement.genomeSize]; - GenomeManagement.setMaskForChildsForMixingWithoutDuplicates(parent1, parent2); - GenomeManagement.setChildsUsingMaskForChilds(parent1, parent2); ! return GenomeManagement.childs; } --- 220,228 ---- if(parent1.Size != parent2.Size) throw new Exception("Genomes must have the same size!"); ! if(setMaskForChildsForMixingWithoutDuplicates(parent1, parent2)) ! setChildsUsingMaskForChilds(parent1, parent2); ! ! return childs; } |
|
From: Marco M. <mi...@us...> - 2005-06-10 18:45:58
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/CallingReportsForRunScripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19231/b7_Scripts/CallingReportsForRunScripts Modified Files: ShowReportFromFile.cs Log Message: Added the function to ShowReportFromFile for retrieving a report, through the ReportShower, from a serialized TransactionHistory object; Added new MenuItem to Main form for creating report from a serialized transaction History; Added new MenuItem to Report form for saving the TransactionHistory on which the current showed report is based Index: ShowReportFromFile.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/CallingReportsForRunScripts/ShowReportFromFile.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ShowReportFromFile.cs 17 Apr 2005 13:31:50 -0000 1.4 --- ShowReportFromFile.cs 10 Jun 2005 18:45:44 -0000 1.5 *************** *** 21,28 **** --- 21,30 ---- */ using System; + using System.Collections; using QuantProject.Scripts; using QuantProject.Business.Timing; using QuantProject.Business.Financial.Accounting; using QuantProject.Business.Financial.Accounting.Reporting; + using QuantProject.Business.Financial.Accounting.Transactions; using QuantProject.Business.DataProviders; using QuantProject.ADT.FileManaging; *************** *** 47,51 **** (Account)ObjectArchiver.Extract(serializedAccountFullPath); Report report = new Report(account, new HistoricalAdjustedQuoteProvider()); ! report.Text = serializedAccountFullPath.Substring(serializedAccountFullPath.LastIndexOf("\\") + 1); ReportShower reportShower = new ReportShower(report); --- 49,54 ---- (Account)ObjectArchiver.Extract(serializedAccountFullPath); Report report = new Report(account, new HistoricalAdjustedQuoteProvider()); ! ! report.Text = serializedAccountFullPath.Substring(serializedAccountFullPath.LastIndexOf("\\") + 1); ReportShower reportShower = new ReportShower(report); *************** *** 74,78 **** --- 77,107 ---- } } + + + + public static void ShowReportFromSerializedTransactionHistory(string serializedTransactionHistoryFullPath) + { + try + { + TransactionHistory transactions = + (TransactionHistory)ObjectArchiver.Extract(serializedTransactionHistoryFullPath); + Account account = new Account("FromSerializedTransactions"); + foreach(Object key in transactions.Keys) + { + foreach(EndOfDayTransaction transaction in (ArrayList)transactions[key]) + { + account.Add(transaction); + } + } + Report report = new Report(account, new HistoricalAdjustedQuoteProvider()); + ReportShower reportShower = new ReportShower(report); + reportShower.Show(); + } + catch(System.Exception ex) + { + System.Windows.Forms.MessageBox.Show(ex.ToString()); + } + } } } |
|
From: Marco M. <mi...@us...> - 2005-06-10 18:45:58
|
Update of /cvsroot/quantproject/QuantProject/b91_QuantProject In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19231/b91_QuantProject Modified Files: Main.cs Log Message: Added the function to ShowReportFromFile for retrieving a report, through the ReportShower, from a serialized TransactionHistory object; Added new MenuItem to Main form for creating report from a serialized transaction History; Added new MenuItem to Report form for saving the TransactionHistory on which the current showed report is based Index: Main.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b91_QuantProject/Main.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Main.cs 23 Mar 2005 21:35:38 -0000 1.14 --- Main.cs 10 Jun 2005 18:45:45 -0000 1.15 *************** *** 22,25 **** --- 22,26 ---- using System; + using System.IO; using System.Drawing; using System.Collections; *************** *** 28,32 **** using QuantProject.Scripts; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; ! //using QuantProject.ADT.Optimizing.Genetic; using QuantProject.Scripts.SimpleTesting; --- 29,33 ---- using QuantProject.Scripts; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; ! using QuantProject.ADT.Optimizing.Genetic; using QuantProject.Scripts.SimpleTesting; *************** *** 34,37 **** --- 35,41 ---- using QuantProject.Scripts.CallingReportsForRunScripts; using QuantProject.Presentation.Reporting.WindowsForm; + using QuantProject.ADT.Statistics; + + *************** *** 44,48 **** public class Principale : System.Windows.Forms.Form { ! private System.Windows.Forms.MainMenu mainMenu1; private System.Windows.Forms.MenuItem menuItem1; private System.Windows.Forms.MenuItem menuItem2; --- 48,54 ---- public class Principale : System.Windows.Forms.Form { ! public static RunEfficientPorfolio runEfficientPortfolio; ! ! private System.Windows.Forms.MainMenu mainMenu1; private System.Windows.Forms.MenuItem menuItem1; private System.Windows.Forms.MenuItem menuItem2; *************** *** 64,67 **** --- 70,74 ---- private System.Windows.Forms.MenuItem menuItemRunReleasingMode; private System.Windows.Forms.MenuItem menuItemShowSavedReport; + private System.Windows.Forms.MenuItem menuItemShowReportFromTransactions; /// <summary> /// Required designer variable. *************** *** 112,115 **** --- 119,123 ---- this.menuItemAccountViewer = new System.Windows.Forms.MenuItem(); this.menuItemShowReportFromAccount = new System.Windows.Forms.MenuItem(); + this.menuItemShowSavedReport = new System.Windows.Forms.MenuItem(); this.menuItemRunReleasingMode = new System.Windows.Forms.MenuItem(); this.menuItem13 = new System.Windows.Forms.MenuItem(); *************** *** 122,126 **** this.menuItem6 = new System.Windows.Forms.MenuItem(); this.menuItem7 = new System.Windows.Forms.MenuItem(); ! this.menuItemShowSavedReport = new System.Windows.Forms.MenuItem(); // // mainMenu1 --- 130,134 ---- this.menuItem6 = new System.Windows.Forms.MenuItem(); this.menuItem7 = new System.Windows.Forms.MenuItem(); ! this.menuItemShowReportFromTransactions = new System.Windows.Forms.MenuItem(); // // mainMenu1 *************** *** 172,176 **** this.menuItemAccountViewer, this.menuItemShowReportFromAccount, ! this.menuItemShowSavedReport}); this.menuItemSavedTests.Text = "Saved Tests"; // --- 180,185 ---- this.menuItemAccountViewer, this.menuItemShowReportFromAccount, ! this.menuItemShowSavedReport, ! this.menuItemShowReportFromTransactions}); this.menuItemSavedTests.Text = "Saved Tests"; // *************** *** 187,190 **** --- 196,205 ---- this.menuItemShowReportFromAccount.Click += new System.EventHandler(this.menuItemShowReportFromAccount_Click); // + // menuItemShowSavedReport + // + this.menuItemShowSavedReport.Index = 2; + this.menuItemShowSavedReport.Text = "Show saved report"; + this.menuItemShowSavedReport.Click += new System.EventHandler(this.menuItemShowSavedReport_Click); + // // menuItemRunReleasingMode // *************** *** 241,249 **** this.menuItem7.Text = ""; // ! // menuItemShowSavedReport // ! this.menuItemShowSavedReport.Index = 2; ! this.menuItemShowSavedReport.Text = "Show saved report"; ! this.menuItemShowSavedReport.Click += new System.EventHandler(this.menuItemShowSavedReport_Click); // // Principale --- 256,264 ---- this.menuItem7.Text = ""; // ! // menuItemShowReportFromTransactions // ! this.menuItemShowReportFromTransactions.Index = 3; ! this.menuItemShowReportFromTransactions.Text = "Show report from transactions"; ! this.menuItemShowReportFromTransactions.Click += new System.EventHandler(this.menuItemShowReportFromTransactions_Click); // // Principale *************** *** 267,276 **** { } [STAThread] static void Main() { ! //try { //new RunMSFTsimpleTest().Run(); --- 282,376 ---- { } + + static void runMilloScripts() + { + /*QuantProject.Principale.Principale.runEfficientPortfolio = + new RunEfficientCTCPorfolio("Test",150,4,60,10,15000,"^SPX", + new DateTime(2004,3,1), + new DateTime(2004,5,31),15,2,0.0, + PortfolioType.ShortAndLong,0.05, + 2);*/ + /*QuantProject.Principale.Principale.runEfficientPortfolio = + new RunTestOptimizedCTCPortfolio("Test",150,4,60,10,25000,"^SPX", + new DateTime(2004,3,1), + new DateTime(2004,3,1).AddDays(60),15,2,0.015, + PortfolioType.ShortAndLong,0.1, + 2);/* + /*QuantProject.Principale.Principale.runEfficientPortfolio = + new RunEfficientCTOPorfolio("Test",150,4,45,10,1000, + "^SPX", + new DateTime(2004,1,1), + new DateTime(2004,1,15), + 0.0, PortfolioType.ShortAndLong, 2);*/ + + QuantProject.Principale.Principale.runEfficientPortfolio = + new RunTestOptimizedCTOPorfolio("Test",150,5,45,10,50000, + "^SPX", + new DateTime(2004,3,1), + new DateTime(2004,3,1).AddDays(45), + 0.0005, PortfolioType.ShortAndLong, 12); + + /*new RunTestOptimizedCTCPortfolio("Test",150,6,90,10,20000, + "^SPX", + new DateTime(2002,10,1), + new DateTime(2002,10,1).AddDays(120), + 5,2,0.0, + PortfolioType.ShortAndLong, 0.50, 10);*/ + + QuantProject.Principale.Principale.runEfficientPortfolio.Run(); + /* QuantProject.Principale.Principale.runEfficientPortfolio = + new RunTestOptimizedCTOPorfolio("Test",150,6,45,10,150000, + "^SPX", + new DateTime(2003,1,1), + new DateTime(2003,1,1).AddDays(45), + 0.0, PortfolioType.OnlyShort, 12); + + QuantProject.Principale.Principale.runEfficientPortfolio.Run(); */ + /* + QuantProject.Principale.Principale.runEfficientPortfolio = + new RunTestOptimizedCTCPortfolio("Test",100,5,120,10,150000, + "^SPX", + new DateTime(2002,10,1), + new DateTime(2002,10,1).AddDays(120), + 5, 0.0, + PortfolioType.ShortAndLong, 0.50, 10); + QuantProject.Principale.Principale.runEfficientPortfolio.Run(); + + QuantProject.Principale.Principale.runEfficientPortfolio = + new RunTestOptimizedCTCPortfolio("Test",150,5,80,15,60000, + "^SPX", + new DateTime(2002,10,1), + new DateTime(2002,10,1).AddDays(80), + 5, 0.0, + PortfolioType.OnlyLong , 0.50, 10); + QuantProject.Principale.Principale.runEfficientPortfolio.Run(); + QuantProject.Principale.Principale.runEfficientPortfolio = + new RunTestOptimizedCTCPortfolio("Test",150,5,160,15,60000, + "^SPX", + new DateTime(2002,10,1), + new DateTime(2002,10,1).AddDays(160), + 5, 0.0, + PortfolioType.ShortAndLong, 0.50, 10); + QuantProject.Principale.Principale.runEfficientPortfolio.Run(); + */ + + /* + QuantProject.Principale.Principale.runEfficientPortfolio = + new RunEfficientCTOPorfolio("Test",500,6,45,15,50000, + "^SPX", + new DateTime(2002,1,1), + new DateTime(2004,12,31), + 0.0, PortfolioType.OnlyLong); + + QuantProject.Principale.Principale.runEfficientPortfolio.Run(); + */ + + } [STAThread] static void Main() { ! try { //new RunMSFTsimpleTest().Run(); *************** *** 285,288 **** --- 385,395 ---- //new RunEfficientPorfolio().Run(); Application.Run(new Principale()); + //geneticOptimizerTest(); + //Application.Run(new OneRankForm()); + //runMilloScripts(); + + //new RunEfficientCTOPorfolio("Test",200,5,60,10,5000, "^SPX", + // new DateTime(2000,1,1), + // new DateTime(2001,12,31)).Run(); // new RunMSFTwalkForward().Run(); *************** *** 298,317 **** } ! //catch ( Exception ex ) { ! //MessageBox.Show( ex.ToString() ) ; } } ! /* private static void geneticOptimizerTest() { IGenomeManager genomeManagerTest = new GenomeManagerTest(5,1,10); ! GeneticOptimizer GO = new GeneticOptimizer(genomeManagerTest); ! GO.KeepOnRunningUntilConvergenceIsReached = true; GO.Run(true); System.Console.WriteLine("\n\nThe best solution found is: " + (string)GO.BestGenome.Meaning + " with {0} generations", GO.GenerationCounter); } ! */ private void menuItem14_Click(object sender, System.EventArgs e) { --- 405,450 ---- } ! catch ( Exception ex ) { ! QuantProject.Principale.Principale.runEfficientPortfolio.SaveScriptResults(); ! writeExceptionToLogFile(ex); } } ! static private void writeExceptionToLogFile(Exception ex) ! { ! string path = Application.ExecutablePath.Substring(0, Application.ExecutablePath.LastIndexOf('\\')) ! + @"\ExceptionLog.txt"; ! if(File.Exists(path)) ! { ! StreamWriter w = File.AppendText(path); ! w.Write("\r\nTime of exception : "); ! w.WriteLine("{0} {1}", DateTime.Now.ToLongDateString(), ! DateTime.Now.ToLocalTime()); ! w.Write("\r\nScript name: {0}", ! QuantProject.Principale.Principale.runEfficientPortfolio.ScriptName ); ! w.Write("\r\nTimer date: {0}", ! QuantProject.Principale.Principale.runEfficientPortfolio.TimerLastDate.ToLongDateString() ); ! ! w.WriteLine("\n :{0}", ex.ToString()); ! w.WriteLine("\n :{0}", ex.StackTrace.ToString()); ! w.WriteLine ("\n-----------------------------------"); ! // Update the underlying file. ! w.Flush(); ! w.Close(); ! } ! ! ! } ! private static void geneticOptimizerTest() { IGenomeManager genomeManagerTest = new GenomeManagerTest(5,1,10); ! GeneticOptimizer GO = new GeneticOptimizer(genomeManagerTest,1000,10); ! //GO.KeepOnRunningUntilConvergenceIsReached = true; GO.Run(true); System.Console.WriteLine("\n\nThe best solution found is: " + (string)GO.BestGenome.Meaning + " with {0} generations", GO.GenerationCounter); } ! private void menuItem14_Click(object sender, System.EventArgs e) { *************** *** 326,332 **** //new RunOneRank().Run(); ! new RunEfficientCTOPorfolio("Test2",100,5,45, 1, 3000, "^SPX", ! new DateTime(2004,10,1), ! new DateTime(2004,10,15)).Run(); // } --- 459,474 ---- //new RunOneRank().Run(); ! //new RunEfficientCTCPorfolio("Test",400,5,90,10,10000, ! // "^SPX", ! // new DateTime(2004,1,1), ! // new DateTime(2004,2,29), ! // 3).Run(); ! ! //this.Close(); ! runMilloScripts(); ! ! //new RunEfficientCTOPorfolio("Test",200,5,60,2,500, "^SPX", ! // new DateTime(2004,1,1), ! // new DateTime(2004,1,15)).Run(); // } *************** *** 375,379 **** catch ( Exception ex ) { ! string notUsed = ex.ToString(); //in this way qP shouldn't stop if running a single script fails ... } --- 517,521 ---- catch ( Exception ex ) { ! ex = ex; //in this way qP shouldn't stop if running a single script fails ... } *************** *** 391,394 **** --- 533,543 ---- } + private void menuItemShowReportFromTransactions_Click(object sender, System.EventArgs e) + { + string chosenPath = this.getPath("Select a serialized TransactionHistory please ..."); + if(chosenPath != "") + ShowReportFromFile.ShowReportFromSerializedTransactionHistory(chosenPath); + } + |
|
From: Marco M. <mi...@us...> - 2005-06-10 18:45:57
|
Update of /cvsroot/quantproject/QuantProject/b5_Presentation/Reporting/WindowsForm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19231/b5_Presentation/Reporting/WindowsForm Modified Files: Report.cs Log Message: Added the function to ShowReportFromFile for retrieving a report, through the ReportShower, from a serialized TransactionHistory object; Added new MenuItem to Main form for creating report from a serialized transaction History; Added new MenuItem to Report form for saving the TransactionHistory on which the current showed report is based Index: Report.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b5_Presentation/Reporting/WindowsForm/Report.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Report.cs 7 Jun 2005 13:54:42 -0000 1.13 --- Report.cs 10 Jun 2005 18:45:44 -0000 1.14 *************** *** 45,48 **** --- 45,49 ---- private System.Windows.Forms.MenuItem saveAccount; private System.Windows.Forms.MenuItem saveReport; + private System.Windows.Forms.MenuItem saveTransactions; private SaveFileDialog saveFileDialog; *************** *** 85,88 **** --- 86,92 ---- this.saveReport = new MenuItem(); this.saveReport.Text = "Save Report"; + + this.saveTransactions = new MenuItem(); + this.saveTransactions.Text = "Save Transactions"; this.file = new MenuItem(); *************** *** 93,101 **** this.file.MenuItems.AddRange(new MenuItem[] {this.saveAccount, ! this.saveReport}); this.Menu = this.mainMenu; this.saveAccount.Click += new System.EventHandler(this.saveAccount_Click); this.saveReport.Click += new System.EventHandler(this.saveReport_Click); ! } --- 97,105 ---- this.file.MenuItems.AddRange(new MenuItem[] {this.saveAccount, ! this.saveReport, this.saveTransactions}); this.Menu = this.mainMenu; this.saveAccount.Click += new System.EventHandler(this.saveAccount_Click); this.saveReport.Click += new System.EventHandler(this.saveReport_Click); ! this.saveTransactions.Click += new System.EventHandler(this.saveTransactions_Click); } *************** *** 165,173 **** } ! #region save account or report private void saveAccount_Click(object sender, System.EventArgs e) { ! this.saveAccountOrReport((MenuItem)sender); } --- 169,177 ---- } ! #region save account or report or transactions private void saveAccount_Click(object sender, System.EventArgs e) { ! this.saveObject((MenuItem)sender); } *************** *** 175,182 **** private void saveReport_Click(object sender, System.EventArgs e) { ! this.saveAccountOrReport((MenuItem)sender); } ! private void saveAccountOrReport_setSaveFileDialog(MenuItem sender) { this.saveFileDialog = new SaveFileDialog(); --- 179,191 ---- private void saveReport_Click(object sender, System.EventArgs e) { ! this.saveObject((MenuItem)sender); } ! private void saveTransactions_Click(object sender, System.EventArgs e) ! { ! this.saveObject((MenuItem)sender); ! } ! ! private void saveObject_setSaveFileDialog(MenuItem sender) { this.saveFileDialog = new SaveFileDialog(); *************** *** 189,193 **** System.Configuration.ConfigurationSettings.AppSettings["ReportsArchive"]; } ! else //else the text property of the menu item sender contains at the end // the word "Account"; so it will be saved an account object --- 198,202 ---- System.Configuration.ConfigurationSettings.AppSettings["ReportsArchive"]; } ! else if(sender.Text.EndsWith("Account")) //else the text property of the menu item sender contains at the end // the word "Account"; so it will be saved an account object *************** *** 197,200 **** --- 206,215 ---- System.Configuration.ConfigurationSettings.AppSettings["AccountsArchive"]; } + else if(sender.Text.EndsWith("Transactions")) + //else the text property of the menu item sender contains at the end + // the word "Transactions"; so it will be saved a TransactionHistory object + { + this.saveFileDialog.DefaultExt = "qPt"; + } this.saveFileDialog.AddExtension = true; *************** *** 207,213 **** } ! private void saveAccountOrReport(MenuItem sender) { ! this.saveAccountOrReport_setSaveFileDialog(sender); this.saveFileDialog.FileOk += new System.ComponentModel.CancelEventHandler(this.fileOk_Click); this.saveFileDialog.ShowDialog(); --- 222,228 ---- } ! private void saveObject(MenuItem sender) { ! this.saveObject_setSaveFileDialog(sender); this.saveFileDialog.FileOk += new System.ComponentModel.CancelEventHandler(this.fileOk_Click); this.saveFileDialog.ShowDialog(); *************** *** 219,225 **** QuantProject.ADT.FileManaging.ObjectArchiver.Archive(this.accountReport, this.saveFileDialog.FileName); ! else QuantProject.ADT.FileManaging.ObjectArchiver.Archive(this.account, this.saveFileDialog.FileName); } --- 234,243 ---- QuantProject.ADT.FileManaging.ObjectArchiver.Archive(this.accountReport, this.saveFileDialog.FileName); ! else if(((SaveFileDialog)sender).Title.EndsWith("Account")) QuantProject.ADT.FileManaging.ObjectArchiver.Archive(this.account, this.saveFileDialog.FileName); + else if(((SaveFileDialog)sender).Title.EndsWith("Transactions")) + QuantProject.ADT.FileManaging.ObjectArchiver.Archive(this.account.Transactions, + this.saveFileDialog.FileName); } |
|
From: Marco M. <mi...@us...> - 2005-06-10 18:35:41
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/TickerSelectors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13326/Downloader/TickerSelectors Modified Files: TickerGroupsViewer.cs Log Message: It now possible to order tickers by clicking on columns'headers Index: TickerGroupsViewer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/TickerSelectors/TickerGroupsViewer.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TickerGroupsViewer.cs 1 Dec 2004 22:54:01 -0000 1.7 --- TickerGroupsViewer.cs 10 Jun 2005 18:35:30 -0000 1.8 *************** *** 61,64 **** --- 61,65 ---- private System.Windows.Forms.MenuItem menuItemTickerSelector; private const string THIRD_COLUMN_NAME = "Element Description"; + private SortOrder lastSorting = SortOrder.None; public TickerGroupsViewer() *************** *** 367,370 **** --- 368,372 ---- // this.listViewGroupsAndTickers.Activation = System.Windows.Forms.ItemActivation.TwoClick; + this.listViewGroupsAndTickers.AllowColumnReorder = true; this.listViewGroupsAndTickers.AllowDrop = true; this.listViewGroupsAndTickers.Dock = System.Windows.Forms.DockStyle.Fill; *************** *** 378,381 **** --- 380,384 ---- this.listViewGroupsAndTickers.DragDrop += new System.Windows.Forms.DragEventHandler(this.listViewGroupsAndTickers_DragDrop); this.listViewGroupsAndTickers.DragEnter += new System.Windows.Forms.DragEventHandler(this.listViewGroupsAndTickers_DragEnter); + this.listViewGroupsAndTickers.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.listViewGroupsAndTickers_ColumnClick); this.listViewGroupsAndTickers.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.listViewGroupsAndTickers_ItemDrag); this.listViewGroupsAndTickers.DragLeave += new System.EventHandler(this.listViewGroupsAndTickers_DragLeave); *************** *** 886,889 **** --- 889,904 ---- //MessageBox.Show("Drag here?"); } + + private void listViewGroupsAndTickers_ColumnClick(object sender, System.Windows.Forms.ColumnClickEventArgs e) + { + if(this.lastSorting == SortOrder.None || + this.lastSorting == SortOrder.Descending) + this.listViewGroupsAndTickers.Sorting = SortOrder.Ascending; + else + this.listViewGroupsAndTickers.Sorting = SortOrder.Descending; + this.listViewGroupsAndTickers.Sort(); + this.lastSorting = this.listViewGroupsAndTickers.Sorting; + this.listViewGroupsAndTickers.Sorting = SortOrder.None; + } |
|
From: Glauco S. <gla...@us...> - 2005-06-07 15:36:34
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/SimpleTesting/OneRank In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2256/b7_Scripts/SimpleTesting/OneRank Modified Files: RunOneRank.cs Log Message: A new MouseUp event handler has been added on the TransactionGrid: it invokes a OneRankForm, initialized so that the InSample optimization can be easily checked. Index: RunOneRank.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/SimpleTesting/OneRank/RunOneRank.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** RunOneRank.cs 30 Mar 2005 23:41:00 -0000 1.9 --- RunOneRank.cs 7 Jun 2005 15:36:24 -0000 1.10 *************** *** 22,26 **** --- 22,30 ---- using System; + using System.Data; + using System.Drawing; + using System.Windows.Forms; + using QuantProject.ADT.FileManaging; using QuantProject.Business.DataProviders; using QuantProject.Business.Financial.Accounting; *************** *** 29,32 **** --- 33,37 ---- using QuantProject.Business.Scripting; using QuantProject.Business.Timing; + using QuantProject.Data.DataProviders; using QuantProject.Presentation.Reporting.WindowsForm; *************** *** 39,44 **** public class RunOneRank : Script { ! private DateTime startDateTime = new DateTime( 2000 , 1 , 1 ); ! private DateTime endDateTime = new DateTime( 2000 , 12 , 31 ); private Account account; private IHistoricalQuoteProvider historicalQuoteProvider = --- 44,49 ---- public class RunOneRank : Script { ! private DateTime startDateTime = new DateTime( 1993 , 1 , 1 ); ! private DateTime endDateTime = new DateTime( 2003 , 12 , 31 ); private Account account; private IHistoricalQuoteProvider historicalQuoteProvider = *************** *** 50,76 **** { } public override void Run() { HistoricalEndOfDayTimer historicalEndOfDayTimer = new IndexBasedEndOfDayTimer( new EndOfDayDateTime( this.startDateTime , EndOfDaySpecificTime.MarketOpen ) , "MSFT" ); ! this.account = new Account( "MSFT" , historicalEndOfDayTimer , new HistoricalEndOfDayDataStreamer( historicalEndOfDayTimer , this.historicalQuoteProvider ) , new HistoricalEndOfDayOrderExecutor( historicalEndOfDayTimer , ! this.historicalQuoteProvider ) , ! new IBCommissionManager() ); ! // this.account = new Account( "MSFT" , historicalEndOfDayTimer , ! // new HistoricalEndOfDayDataStreamer( historicalEndOfDayTimer , ! // this.historicalQuoteProvider ) , ! // new HistoricalEndOfDayOrderExecutor( historicalEndOfDayTimer , ! // this.historicalQuoteProvider ) ); OneRank oneRank = new OneRank( account , this.endDateTime ); Report report = new Report( this.account , this.historicalQuoteProvider ); ! report.Show( "WFT One Rank" , 1 , new EndOfDayDateTime( this.endDateTime , EndOfDaySpecificTime.MarketClose ) , ! "MSFT" ); } } --- 55,114 ---- { } + private void showTransactionDataGridContextMenu( object sender , + MouseEventArgs eventArgs ) + { + DataGrid dataGrid = (DataGrid)sender; + Point point = new Point( eventArgs.X , eventArgs.Y ); + DataGrid.HitTestInfo hitTestInfo = dataGrid.HitTest( point ); + DataTable dataTable = (DataTable)dataGrid.DataSource; + DataRow dataRow = dataTable.Rows[ hitTestInfo.Row ]; + // MessageBox.Show( dataRow[ "DateTime" ].ToString() ); + DateTime rowDateTime = (DateTime)dataRow[ "DateTime" ]; + string rowTicker = (string)dataRow[ "InstrumentKey"]; + OneRankForm oneRankForm = new OneRankForm(); + oneRankForm.FirstDateTime = rowDateTime.AddDays( -30 ); + oneRankForm.LastDateTime = rowDateTime; + oneRankForm.Ticker = rowTicker; + oneRankForm.Show(); + } + private void mouseEventHandler( object sender , MouseEventArgs eventArgs ) + { + if ( eventArgs.Button == MouseButtons.Right ) + this.showTransactionDataGridContextMenu( sender , eventArgs ); + } public override void Run() { + // HistoricalDataProvider.MinDate = this.startDateTime; + // HistoricalDataProvider.MaxDate = this.endDateTime.AddDays( 10 ); HistoricalEndOfDayTimer historicalEndOfDayTimer = new IndexBasedEndOfDayTimer( new EndOfDayDateTime( this.startDateTime , EndOfDaySpecificTime.MarketOpen ) , "MSFT" ); ! ! // with IB commission ! // this.account = new Account( "MSFT" , historicalEndOfDayTimer , ! // new HistoricalEndOfDayDataStreamer( historicalEndOfDayTimer , ! // this.historicalQuoteProvider ) , ! // new HistoricalEndOfDayOrderExecutor( historicalEndOfDayTimer , ! // this.historicalQuoteProvider ) , ! // new IBCommissionManager() ); ! ! // with no commission ! this.account = new Account( "SLR" , historicalEndOfDayTimer , new HistoricalEndOfDayDataStreamer( historicalEndOfDayTimer , this.historicalQuoteProvider ) , new HistoricalEndOfDayOrderExecutor( historicalEndOfDayTimer , ! this.historicalQuoteProvider ) ); OneRank oneRank = new OneRank( account , this.endDateTime ); Report report = new Report( this.account , this.historicalQuoteProvider ); ! report.Create( "WFT One Rank" , 1 , new EndOfDayDateTime( this.endDateTime , EndOfDaySpecificTime.MarketClose ) , ! "SLR" ); ! report.TransactionGrid.MouseUp += ! new MouseEventHandler( this.mouseEventHandler ); ! // ObjectArchiver.Archive( report.AccountReport , ! // @"C:\Documents and Settings\Glauco\Desktop\reports\runOneRank.qPr" ); ! report.Show(); } } |
|
From: Glauco S. <gla...@us...> - 2005-06-07 15:32:15
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardOneRank In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31921/b7_Scripts/WalkForwardTesting/WalkForwardOneRank Modified Files: RunWalkForwardOneRank.cs Log Message: A new MouseUp event handler has been added on the TransactionGrid: it invokes a OneRankForm, initialized so that the InSample optimization can be easily checked. Index: RunWalkForwardOneRank.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardOneRank/RunWalkForwardOneRank.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** RunWalkForwardOneRank.cs 24 Apr 2005 15:52:23 -0000 1.9 --- RunWalkForwardOneRank.cs 7 Jun 2005 15:32:06 -0000 1.10 *************** *** 24,28 **** --- 24,30 ---- using System.Collections; using System.Data; + using System.Drawing; using System.Threading; + using System.Windows.Forms; using QuantProject.ADT; *************** *** 39,42 **** --- 41,45 ---- using QuantProject.Data.DataProviders; using QuantProject.Presentation.Reporting.WindowsForm; + using QuantProject.Scripts.SimpleTesting; namespace QuantProject.Scripts.WalkForwardTesting.WalkForwardOneRank *************** *** 51,56 **** --- 54,62 ---- new HistoricalAdjustedQuoteProvider(); private ReportTable reportTable; + private EndOfDayDateTime startDateTime; private EndOfDayDateTime endDateTime; + int numberDaysForPerformanceCalculation; + private int numIntervalDays; *************** *** 69,73 **** new DateTime( 1998 , 1 , 1 ) , EndOfDaySpecificTime.MarketOpen ); this.endDateTime = new EndOfDayDateTime( ! new DateTime( 1998 , 1 , 20 ) , EndOfDaySpecificTime.OneHourAfterMarketClose ); this.numIntervalDays = 1; } --- 75,80 ---- new DateTime( 1998 , 1 , 1 ) , EndOfDaySpecificTime.MarketOpen ); this.endDateTime = new EndOfDayDateTime( ! new DateTime( 1998 , 12 , 31 ) , EndOfDaySpecificTime.OneHourAfterMarketClose ); ! this.numberDaysForPerformanceCalculation = 1800; this.numIntervalDays = 1; } *************** *** 92,96 **** private void run_initializeEndOfDayTimerHandler() { ! this.endOfDayTimerHandler = new EndOfDayTimerHandler( 200 , 20 , 5 , 360 , 30 , this.account ); // this.endOfDayTimerHandler = new EndOfDayTimerHandler( 4 , 3 , 2 , 100 , 30 , --- 99,104 ---- private void run_initializeEndOfDayTimerHandler() { ! this.endOfDayTimerHandler = new EndOfDayTimerHandler( 200 , 20 , 5 , ! this.numberDaysForPerformanceCalculation , 30 , this.account ); // this.endOfDayTimerHandler = new EndOfDayTimerHandler( 4 , 3 , 2 , 100 , 30 , *************** *** 144,147 **** --- 152,180 ---- this.account.AddCash( 30000 ); } + #region oneHourAfterMarketCloseEventHandler + private void showOneRankForm( object sender , + MouseEventArgs eventArgs ) + { + DataGrid dataGrid = (DataGrid)sender; + Point point = new Point( eventArgs.X , eventArgs.Y ); + DataGrid.HitTestInfo hitTestInfo = dataGrid.HitTest( point ); + DataTable dataTable = (DataTable)dataGrid.DataSource; + DataRow dataRow = dataTable.Rows[ hitTestInfo.Row ]; + // MessageBox.Show( dataRow[ "DateTime" ].ToString() ); + DateTime rowDateTime = (DateTime)dataRow[ "DateTime" ]; + string rowTicker = (string)dataRow[ "InstrumentKey"]; + OneRankForm oneRankForm = new OneRankForm(); + oneRankForm.FirstDateTime = + rowDateTime.AddDays( -this.numberDaysForPerformanceCalculation ); + oneRankForm.LastDateTime = rowDateTime; + oneRankForm.Ticker = rowTicker; + oneRankForm.Show(); + } + private void mouseEventHandler( object sender , MouseEventArgs eventArgs ) + { + if ( eventArgs.Button == MouseButtons.Right ) + this.showOneRankForm( sender , eventArgs ); + } + #endregion public void oneHourAfterMarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) *************** *** 153,160 **** this.account.EndOfDayTimer.Stop(); // this.progressBarForm.Close(); ! ObjectArchiver.Archive( this.account , ! @"C:\Documents and Settings\Glauco\Desktop\reports\final.qP" ); Report report = new Report( this.account , this.historicalQuoteProvider ); ! report.Show( "WFT One Rank" , this.numIntervalDays , this.endDateTime , "MSFT" ); } else --- 186,196 ---- this.account.EndOfDayTimer.Stop(); // this.progressBarForm.Close(); ! // ObjectArchiver.Archive( this.account , ! // @"C:\Documents and Settings\Glauco\Desktop\reports\final.qP" ); Report report = new Report( this.account , this.historicalQuoteProvider ); ! report.Create( "WFT One Rank" , this.numIntervalDays , this.endDateTime , "MSFT" ); ! report.TransactionGrid.MouseUp += ! new MouseEventHandler( this.mouseEventHandler ); ! report.Show(); } else |
|
From: Glauco S. <gla...@us...> - 2005-06-07 15:21:56
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardOneRank In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26543/b7_Scripts/WalkForwardTesting/WalkForwardOneRank Modified Files: EligibleTickers.cs Log Message: setTickers_buildQuickly_getSelectedTickers is a new private method to be used for debug purposes. It is much faster than the standard setTickers_build_getSelectedTickers method (comment/uncomment to switch among the two behaviors). Index: EligibleTickers.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardOneRank/EligibleTickers.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** EligibleTickers.cs 27 Feb 2005 19:56:09 -0000 1.3 --- EligibleTickers.cs 7 Jun 2005 15:21:43 -0000 1.4 *************** *** 45,61 **** #region SetTickers ! private void setTickers_build( DateTime dateTime ) { SelectorByLiquidity mostLiquid = new SelectorByLiquidity("Test", false , dateTime.AddDays( - this.numDaysToComputeLiquidity ) , dateTime , ! this.numberEligibleTickersToBeChosen ); DataTable mostLiquidTickers = mostLiquid.GetTableOfSelectedTickers(); SelectorByQuotationAtEachMarketDay quotedInEachMarketDayFromMostLiquid = new SelectorByQuotationAtEachMarketDay( mostLiquidTickers, ! false, dateTime.AddDays( - this.numberDaysForPerformanceCalculation ) , ! dateTime, this.numberEligibleTickersToBeChosen,"^SPX"); ! DataTable selectedTickers = ! quotedInEachMarketDayFromMostLiquid.GetTableOfSelectedTickers(); foreach ( DataRow dataRow in selectedTickers.Rows ) this.Add( dataRow[ "tiTicker" ].ToString() , --- 45,75 ---- #region SetTickers ! private DataTable setTickers_build_getSelectedTickers( DateTime dateTime ) { SelectorByLiquidity mostLiquid = new SelectorByLiquidity("Test", false , dateTime.AddDays( - this.numDaysToComputeLiquidity ) , dateTime , ! this.numberEligibleTickersToBeChosen ); DataTable mostLiquidTickers = mostLiquid.GetTableOfSelectedTickers(); SelectorByQuotationAtEachMarketDay quotedInEachMarketDayFromMostLiquid = new SelectorByQuotationAtEachMarketDay( mostLiquidTickers, ! false, dateTime.AddDays( - this.numberDaysForPerformanceCalculation ) , ! dateTime, this.numberEligibleTickersToBeChosen,"^SPX"); ! return quotedInEachMarketDayFromMostLiquid.GetTableOfSelectedTickers(); ! } ! private DataTable setTickers_buildQuickly_getSelectedTickers() ! { ! DataTable returnValue = ! new QuantProject.Data.DataTables.Tickers_tickerGroups( "millo" ); ! returnValue.Columns[ 0 ].ColumnName = "tiTicker"; ! return returnValue; ! } ! private void setTickers_build( DateTime dateTime ) ! { ! // for fast debug, comment the following line ! DataTable selectedTickers = setTickers_build_getSelectedTickers( dateTime ); ! // for fast debug, uncomment the following line ! // DataTable selectedTickers = setTickers_buildQuickly_getSelectedTickers(); ! foreach ( DataRow dataRow in selectedTickers.Rows ) this.Add( dataRow[ "tiTicker" ].ToString() , |
|
From: Glauco S. <gla...@us...> - 2005-06-07 15:19:09
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardOneRank In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25264/b7_Scripts/WalkForwardTesting/WalkForwardOneRank Modified Files: BestPerformingTickers.cs Log Message: Best performing tickers are properly computed now: EstimatedObject(s) are used, instead of SortedList. Index: BestPerformingTickers.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardOneRank/BestPerformingTickers.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** BestPerformingTickers.cs 30 May 2005 18:32:35 -0000 1.9 --- BestPerformingTickers.cs 7 Jun 2005 15:18:56 -0000 1.10 *************** *** 49,53 **** private ArrayList eligibleAccounts; ! private SortedList tickersWithGoodness; private DateTime lastUpdate; --- 49,53 ---- private ArrayList eligibleAccounts; ! private ArrayList tickersWithGoodness; private DateTime lastUpdate; *************** *** 64,68 **** this.numberDaysForPerformanceCalculation = numberDaysForPerformanceCalculation; this.eligibleAccounts = new ArrayList(); ! this.tickersWithGoodness = new SortedList(); } --- 64,68 ---- this.numberDaysForPerformanceCalculation = numberDaysForPerformanceCalculation; this.eligibleAccounts = new ArrayList(); ! this.tickersWithGoodness = new ArrayList(); } *************** *** 127,131 **** this.historicalQuoteProvider ) ); OneRank oneRank = new OneRank( account , dateTime ); ! this.tickersWithGoodness.Add( account.Key , account.Goodness ); } private void setTickers_build( EligibleTickers eligibleTickers , DateTime dateTime ) --- 127,131 ---- this.historicalQuoteProvider ) ); OneRank oneRank = new OneRank( account , dateTime ); ! this.tickersWithGoodness.Add( new EstimatedObject( account.Key , account.Goodness ) ); } private void setTickers_build( EligibleTickers eligibleTickers , DateTime dateTime ) *************** *** 151,159 **** } } for ( int index=this.tickersWithGoodness.Count - 1 ; index >= this.tickersWithGoodness.Count - this.numberBestPerformingTickers ; index-- ) { ! this.Add( this.tickersWithGoodness.GetKey( index ) ); } } --- 151,160 ---- } } + this.tickersWithGoodness.Sort(); for ( int index=this.tickersWithGoodness.Count - 1 ; index >= this.tickersWithGoodness.Count - this.numberBestPerformingTickers ; index-- ) { ! this.Add( ((EstimatedObject)this.tickersWithGoodness[ index ]).ObjectToBeEstimated ); } } |
|
From: Glauco S. <gla...@us...> - 2005-06-07 15:16:48
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/SimpleTesting/OneRank In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24318/b7_Scripts/SimpleTesting/OneRank Added Files: OneRankForm.cs Log Message: A Form to backtest different OneRank scripts, with different tickers and/or time intervals --- NEW FILE: OneRankForm.cs --- using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using QuantProject.Business.DataProviders; using QuantProject.Business.Financial.Accounting; using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Timing; using QuantProject.Presentation.Reporting.WindowsForm; namespace QuantProject.Scripts.SimpleTesting { /// <summary> /// Summary description for OneRankForm. /// </summary> public class OneRankForm : System.Windows.Forms.Form { private System.Windows.Forms.TextBox ticker; private System.Windows.Forms.Label label1; private System.Windows.Forms.ToolTip toolTip1; private System.Windows.Forms.DateTimePicker firstDateTime; private System.Windows.Forms.DateTimePicker lastDateTime; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label3; private System.Windows.Forms.Button start; private System.ComponentModel.IContainer components; private Account account; private HistoricalAdjustedQuoteProvider historicalQuoteProvider = new HistoricalAdjustedQuoteProvider(); public string Ticker { set { this.ticker.Text = value; } } public DateTime FirstDateTime { set { this.firstDateTime.Value = value; } } public DateTime LastDateTime { set { this.lastDateTime.Value = value; } } public OneRankForm() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.start = new System.Windows.Forms.Button(); this.ticker = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.firstDateTime = new System.Windows.Forms.DateTimePicker(); this.lastDateTime = new System.Windows.Forms.DateTimePicker(); this.label2 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // start // this.start.Location = new System.Drawing.Point(160, 136); this.start.Name = "start"; this.start.TabIndex = 0; this.start.Text = "button1"; this.start.Click += new System.EventHandler(this.start_Click); // // ticker // this.ticker.Location = new System.Drawing.Point(120, 16); this.ticker.Name = "ticker"; this.ticker.TabIndex = 1; this.ticker.Text = ""; this.ticker.TextChanged += new System.EventHandler(this.textBox1_TextChanged); // // label1 // this.label1.Location = new System.Drawing.Point(16, 16); this.label1.Name = "label1"; this.label1.TabIndex = 2; this.label1.Text = "Ticker:"; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; this.label1.Click += new System.EventHandler(this.label1_Click); // // firstDateTime // this.firstDateTime.Location = new System.Drawing.Point(128, 56); this.firstDateTime.Name = "firstDateTime"; this.firstDateTime.TabIndex = 3; // // lastDateTime // this.lastDateTime.Location = new System.Drawing.Point(128, 88); this.lastDateTime.Name = "lastDateTime"; this.lastDateTime.TabIndex = 4; // // label2 // this.label2.Location = new System.Drawing.Point(24, 56); this.label2.Name = "label2"; this.label2.TabIndex = 5; this.label2.Text = "First Date:"; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // // label3 // this.label3.Location = new System.Drawing.Point(24, 88); this.label3.Name = "label3"; this.label3.TabIndex = 6; this.label3.Text = "Last Date:"; this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // // OneRankForm // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(424, 273); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.label3, this.label2, this.lastDateTime, this.firstDateTime, this.label1, this.ticker, this.start}); this.Name = "OneRankForm"; this.Text = "OneRankForm"; this.ResumeLayout(false); } #endregion private void textBox1_TextChanged(object sender, System.EventArgs e) { } private void label1_Click(object sender, System.EventArgs e) { } #region start_Click private void start_Click_initializeAccount() { HistoricalEndOfDayTimer historicalEndOfDayTimer = new IndexBasedEndOfDayTimer( new EndOfDayDateTime( this.firstDateTime.Value , EndOfDaySpecificTime.MarketOpen ) , this.ticker.Text ); // with IB commission // this.account = new Account( "MSFT" , historicalEndOfDayTimer , // new HistoricalEndOfDayDataStreamer( historicalEndOfDayTimer , // this.historicalQuoteProvider ) , // new HistoricalEndOfDayOrderExecutor( historicalEndOfDayTimer , // this.historicalQuoteProvider ) , // new IBCommissionManager() ); // with no commission this.account = new Account( this.ticker.Text , historicalEndOfDayTimer , new HistoricalEndOfDayDataStreamer( historicalEndOfDayTimer , this.historicalQuoteProvider ) , new HistoricalEndOfDayOrderExecutor( historicalEndOfDayTimer , this.historicalQuoteProvider ) ); } private void start_Click(object sender, System.EventArgs e) { start_Click_initializeAccount(); OneRank oneRank = new OneRank( this.account , this.lastDateTime.Value ); Report report = new Report( this.account , this.historicalQuoteProvider ); report.Create( "WFT One Rank" , 1 , new EndOfDayDateTime( this.lastDateTime.Value , EndOfDaySpecificTime.MarketClose ) , this.ticker.Text ); report.Show(); } #endregion } } |
|
From: Glauco S. <gla...@us...> - 2005-06-07 15:12:31
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22606/b1_ADT Added Files: EstimatedObject.cs Log Message: An object along with its estimation --- NEW FILE: EstimatedObject.cs --- /* QuantProject - Quantitative Finance Library EstimatedObject.cs Copyright (C) 2003 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; namespace QuantProject.ADT { /// <summary> /// An object along with its estimation /// </summary> public class EstimatedObject : IComparable { private object objectToBeEstimated; private IComparable estimation; public object ObjectToBeEstimated { get { return this.objectToBeEstimated; } } public IComparable Estimation { get { return this.estimation; } } public EstimatedObject( object objectToBeEstimated , IComparable estimation ) { this.objectToBeEstimated = objectToBeEstimated; this.estimation = estimation; } public int CompareTo( object obj ) { int returnValue = -5; try { returnValue = this.estimation.CompareTo( ((EstimatedObject)obj).Estimation ); } catch (Exception ex) { string message = ex.Message; } return returnValue; } } } |
|
From: Glauco S. <gla...@us...> - 2005-06-07 15:09:44
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21269/b7_Scripts Modified Files: b7_Scripts.csproj Log Message: SimpleTesting\OneRank\OneRankForm.cs has been added Index: b7_Scripts.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/b7_Scripts.csproj,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** b7_Scripts.csproj 2 Jun 2005 18:00:48 -0000 1.27 --- b7_Scripts.csproj 7 Jun 2005 15:09:35 -0000 1.28 *************** *** 139,142 **** --- 139,152 ---- /> <File + RelPath = "SimpleTesting\OneRank\OneRankForm.cs" + SubType = "Form" + BuildAction = "Compile" + /> + <File + RelPath = "SimpleTesting\OneRank\OneRankForm.resx" + DependentUpon = "OneRankForm.cs" + BuildAction = "EmbeddedResource" + /> + <File RelPath = "SimpleTesting\OneRank\RunOneRank.cs" SubType = "Code" |
|
From: Glauco S. <gla...@us...> - 2005-06-07 15:08:22
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20610/b1_ADT Modified Files: b1_ADT.csproj Log Message: EstimatedObject.cs has been added Index: b1_ADT.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/b1_ADT.csproj,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** b1_ADT.csproj 26 May 2005 22:52:28 -0000 1.15 --- b1_ADT.csproj 7 Jun 2005 15:08:13 -0000 1.16 *************** *** 103,106 **** --- 103,111 ---- /> <File + RelPath = "EstimatedObject.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "ExtendedDataTable.cs" SubType = "Component" |
|
From: Glauco S. <gla...@us...> - 2005-06-07 15:06:51
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19891/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows Modified Files: MaxEquityDrawDown.cs Log Message: Bug fixed. Max Draw Down is properly computed, now Index: MaxEquityDrawDown.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows/MaxEquityDrawDown.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MaxEquityDrawDown.cs 15 Feb 2005 19:09:03 -0000 1.2 --- MaxEquityDrawDown.cs 7 Jun 2005 15:06:21 -0000 1.3 *************** *** 17,22 **** { this.maxEquityValue = Math.Max( this.maxEquityValue , (double)dataRow[ "AccountValue" ] ); ! this.drawDown = ! Math.Max( this.drawDown , this.maxEquityValue - (double)dataRow[ "AccountValue" ] ); } private void setDrawDown() --- 17,23 ---- { this.maxEquityValue = Math.Max( this.maxEquityValue , (double)dataRow[ "AccountValue" ] ); ! this.drawDown = Math.Max( this.drawDown , ! ( ( this.maxEquityValue - (double)dataRow[ "AccountValue" ] ) / ! this.maxEquityValue ) ); } private void setDrawDown() *************** *** 32,37 **** this.rowDescription = "Max equity drawdown (%)"; setDrawDown(); ! this.rowValue = this.drawDown/this.maxEquityValue*100; ! } } --- 33,37 ---- this.rowDescription = "Max equity drawdown (%)"; setDrawDown(); ! this.rowValue = this.drawDown*100; } } |
|
From: Glauco S. <gla...@us...> - 2005-06-07 13:54:55
|
Update of /cvsroot/quantproject/QuantProject/b5_Presentation/Reporting/WindowsForm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18436/b5_Presentation/Reporting/WindowsForm Modified Files: Report.cs Log Message: Added the AccountReport property Index: Report.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b5_Presentation/Reporting/WindowsForm/Report.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Report.cs 4 Jun 2005 15:17:32 -0000 1.12 --- Report.cs 7 Jun 2005 13:54:42 -0000 1.13 *************** *** 47,50 **** --- 47,60 ---- private SaveFileDialog saveFileDialog; + public AccountReport AccountReport + { + get + { + AccountReport returnValue = this.accountReport; + if ( this.accountReport == null ) + throw new Exception( "The AccountReport has not been created yet!" ); + return returnValue; + } + } public ReportGrid TransactionGrid { *************** *** 63,66 **** --- 73,77 ---- this.account = this.accountReport.Account; this.initializeComponent(); + this.create_populateForm(); } |
|
From: Marco M. <mi...@us...> - 2005-06-02 18:11:47
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Statistics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22873/b1_ADT/Statistics Modified Files: NormalDistribution.cs Log Message: Fixed bug in the constructor method for the normal distribution class (the standard deviation must be > 0; otherwise an exception is raised) In addition, new exceptions are now raised in some methods of the class, for gaining more control on the code Index: NormalDistribution.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Statistics/NormalDistribution.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NormalDistribution.cs 14 Apr 2005 18:28:24 -0000 1.3 --- NormalDistribution.cs 2 Jun 2005 18:11:37 -0000 1.4 *************** *** 43,47 **** public NormalDistribution(double average, double stdDeviation) { ! if(stdDeviation < 0) throw new Exception("Standard deviation must be > 0!"); --- 43,47 ---- public NormalDistribution(double average, double stdDeviation) { ! if(stdDeviation <= 0) throw new Exception("Standard deviation must be > 0!"); *************** *** 60,64 **** public double GetProbabilityDensityValue(double x) { ! double y; y = Math.Pow(Math.E,(-Math.Pow(x-this.average,2) /(2*this.stdDeviation*this.stdDeviation))) --- 60,67 ---- public double GetProbabilityDensityValue(double x) { ! if(Double.IsInfinity(x) || Double.IsNaN(x)) ! throw new Exception("Density value of x is not computable!"); ! ! double y = 0; y = Math.Pow(Math.E,(-Math.Pow(x-this.average,2) /(2*this.stdDeviation*this.stdDeviation))) *************** *** 74,78 **** public double GetProbability(double y) { ! return this.GetProbability(-this.infinity, y); } --- 77,83 ---- public double GetProbability(double y) { ! if(Double.IsInfinity(y) || Double.IsNaN(y)) ! throw new Exception("Prob(Y<y) is not computable!"); ! return this.GetProbability(-this.infinity, y); } *************** *** 83,89 **** public double GetProbability(double a, double b) { ! return CalculusApproximation.GetArea((IPdfDefiner)this,a,b, ! this.numOfIntervalsForPDFIntegralApproximation); } --- 88,98 ---- public double GetProbability(double a, double b) { ! if( Double.IsInfinity(a) || Double.IsNaN(a) || ! Double.IsInfinity(b) || Double.IsNaN(b) ) ! throw new Exception("Prob(a<Y<b) is not computable!"); ! ! return CalculusApproximation.GetArea((IPdfDefiner)this,a,b, ! this.numOfIntervalsForPDFIntegralApproximation); } |
|
From: Marco M. <mi...@us...> - 2005-06-02 18:06:29
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19794/b2_DataAccess/Tables Modified Files: Quotes.cs Log Message: Fixed bug in the isAtLeastOneValueChanged method (the method is used by the TickerDownloader object) Index: Quotes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables/Quotes.cs,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Quotes.cs 4 May 2005 18:25:51 -0000 1.25 --- Quotes.cs 2 Jun 2005 18:06:17 -0000 1.26 *************** *** 318,355 **** #region IsAdjustedCloseToCloseRatioChanged private static bool isAtLeastOneValueChanged(DataTable tableDB, DataTable tableSource) { ! try { ! int numRows = tableDB.Rows.Count; ! DateTime date; ! float adjCTCInDatabase; ! float adjCTCInSource; ! double absoluteDifference; ! DataRow rowToCheck; ! for(int i = 0;i != numRows;i++) { ! date = (DateTime)tableDB.Rows[i][Quotes.Date]; ! adjCTCInDatabase = (float)tableDB.Rows[i][Quotes.AdjustedCloseToCloseRatio]; ! rowToCheck = tableSource.Rows.Find(date); ! if(rowToCheck != null) ! { ! adjCTCInSource = (float)rowToCheck[Quotes.AdjustedCloseToCloseRatio]; ! absoluteDifference = Math.Abs(adjCTCInDatabase - adjCTCInSource); ! if(absoluteDifference > ConstantsProvider.MaxDifferenceForCloseToCloseRatios ) ! { ! Quotes.DateWithDifferentCloseToClose = date; ! return true; ! } ! } } } ! catch(Exception ex) ! { ! string notUsed = ex.ToString(); ! } ! return false; } --- 318,356 ---- #region IsAdjustedCloseToCloseRatioChanged + + private static void isAtLeastOneValueChanged_setPrimaryKey(DataTable tableToBeSet) + { + DataColumn[] columnPrimaryKeys = new DataColumn[1]; + columnPrimaryKeys[0] = tableToBeSet.Columns[Quotes.Date]; + tableToBeSet.PrimaryKey = columnPrimaryKeys; + } private static bool isAtLeastOneValueChanged(DataTable tableDB, DataTable tableSource) { ! bool returnValue = false; ! int numRows = tableDB.Rows.Count; ! DateTime date; ! float adjCTCInDatabase, adjCTCInSource; ! double absoluteDifference; ! DataRow rowToCheck; ! for(int i = 0;i != numRows;i++) { ! date = (DateTime)tableDB.Rows[i][Quotes.Date]; ! adjCTCInDatabase = (float)tableDB.Rows[i][Quotes.AdjustedCloseToCloseRatio]; ! isAtLeastOneValueChanged_setPrimaryKey(tableSource); ! rowToCheck = tableSource.Rows.Find(date); ! if(rowToCheck != null) { ! adjCTCInSource = (float)rowToCheck[Quotes.AdjustedCloseToCloseRatio]; ! absoluteDifference = Math.Abs(adjCTCInDatabase - adjCTCInSource); ! if(absoluteDifference > ConstantsProvider.MaxDifferenceForCloseToCloseRatios ) ! { ! Quotes.DateWithDifferentCloseToClose = date; ! returnValue = true; ! } } } ! return returnValue; } |