quantproject-developers Mailing List for QuantProject (Page 17)
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: Marco M. <mi...@us...> - 2009-08-30 15:57:17
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv23402/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables Modified Files: RoundTrades.cs Log Message: Fixed minor bug Index: RoundTrades.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables/RoundTrades.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RoundTrades.cs 30 Mar 2009 21:35:23 -0000 1.4 --- RoundTrades.cs 30 Aug 2009 15:57:08 -0000 1.5 *************** *** 123,127 **** getRoundTradeTable_setRows( roundTradeDataTable ); DataTable roundTradeDataTable_ordered = ! ExtendedDataTable.CopyAndSort(roundTradeDataTable, "EntryDate", true); return roundTradeDataTable_ordered; } --- 123,128 ---- getRoundTradeTable_setRows( roundTradeDataTable ); DataTable roundTradeDataTable_ordered = ! ExtendedDataTable.CopyAndSort(roundTradeDataTable, "ExitPrice > 0", ! "EntryDate", true); return roundTradeDataTable_ordered; } |
|
From: Marco M. <mi...@us...> - 2009-08-30 15:56:07
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv23219/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables Modified Files: Summary.cs Log Message: AverageShortTradePercentageReturn summary row has been added to Summary Index: Summary.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables/Summary.cs,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Summary.cs 21 Mar 2009 09:55:33 -0000 1.24 --- Summary.cs 30 Aug 2009 15:55:55 -0000 1.25 *************** *** 37,40 **** --- 37,41 ---- private NumberWinningLongTrades numberWinningLongTrades; private AverageLongTradePercentageReturn averageLongTradePercentageReturn; + private AverageShortTradePercentageReturn averageShortTradePercentageReturn; private NumberWinningShortTrades numberWinningShortTrades; private TotalNumberOfLongTrades totalNumberOfLongTrades; *************** *** 161,164 **** --- 162,169 ---- get { return this.averageLongTradePercentageReturn; } } + public AverageShortTradePercentageReturn AverageShortTradePercentageReturn + { + get { return this.averageShortTradePercentageReturn; } + } public TotalNumberOfShortTrades TotalNumberOfShortTrades { *************** *** 290,293 **** --- 295,299 ---- this.numberWinningLongTrades = new NumberWinningLongTrades( this ); this.averageLongTradePercentageReturn = new AverageLongTradePercentageReturn( this ); + this.averageShortTradePercentageReturn = new AverageShortTradePercentageReturn( this ); this.totalNumberOfShortTrades = new TotalNumberOfShortTrades( this ); this.numberWinningShortTrades = new NumberWinningShortTrades( this ); |
|
From: Marco M. <mi...@us...> - 2009-08-30 15:54:23
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv23145/b4_Business/a05_Timing Modified Files: IndexBasedEndOfDayTimer.cs Log Message: The isDone method has been overriden Index: IndexBasedEndOfDayTimer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing/IndexBasedEndOfDayTimer.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** IndexBasedEndOfDayTimer.cs 29 Sep 2008 21:22:45 -0000 1.10 --- IndexBasedEndOfDayTimer.cs 30 Aug 2009 15:54:12 -0000 1.11 *************** *** 112,115 **** --- 112,123 ---- // } + protected override bool isDone() + { + bool lastDateHasAlreadyBeenLaunched; + lastDateHasAlreadyBeenLaunched = + this.IndexQuotes.Rows.Count - 1 == this.currentDateArrayPosition; + return lastDateHasAlreadyBeenLaunched; + } + #region moveNext private void moveNext_with_currentDateTime_properlyInitialized() |
|
From: Marco M. <mi...@us...> - 2009-08-30 15:46:58
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Optimizing/Decoding In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv22386/b4_Business/a2_Strategies/Optimizing/Decoding Modified Files: BasicDecoderForTestingPositions.cs Log Message: The class is not abstract anymore Index: BasicDecoderForTestingPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Optimizing/Decoding/BasicDecoderForTestingPositions.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** BasicDecoderForTestingPositions.cs 29 Sep 2008 21:14:23 -0000 1.8 --- BasicDecoderForTestingPositions.cs 30 Aug 2009 15:46:50 -0000 1.9 *************** *** 38,42 **** /// </summary> [Serializable] ! public abstract class BasicDecoderForTestingPositions : IDecoderForTestingPositions { --- 38,42 ---- /// </summary> [Serializable] ! public class BasicDecoderForTestingPositions : IDecoderForTestingPositions { *************** *** 50,55 **** /// </summary> /// <returns></returns> ! protected abstract string getDescription(); ! public string Description { --- 50,57 ---- /// </summary> /// <returns></returns> ! protected virtual string getDescription() ! { ! return "BscFrTstngPstns"; ! } public string Description { *************** *** 118,122 **** #endregion decodeSignedTickers ! protected abstract TestingPositions getMeaningForUndecodable(); #region isDecodable --- 120,127 ---- #endregion decodeSignedTickers ! protected virtual TestingPositions getMeaningForUndecodable() ! { ! return new TestingPositions(); ! } #region isDecodable *************** *** 154,157 **** --- 159,174 ---- } + protected virtual double[] getUnsignedWeights(SignedTickers signedTickers) + { + //in this implementation encoded doesn't contain + //information for weights: so weights are all the same + double[] weights = new double[this.tickerRelatedGeneValues.Length]; + for(int i = 0; i<weights.Length; i++) + { + weights[i] = 1.0 / weights.Length; + } + return weights; + } + protected virtual TestingPositions getTestingPositions( double[] weights , |
|
From: Marco M. <mi...@us...> - 2009-08-30 15:45:05
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv22227/b1_ADT/Optimizing/Genetic Modified Files: GeneticOptimizer.cs Log Message: Some methods have been commented out Index: GeneticOptimizer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/GeneticOptimizer.cs,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** GeneticOptimizer.cs 19 Jan 2008 18:59:19 -0000 1.27 --- GeneticOptimizer.cs 30 Aug 2009 15:44:53 -0000 1.28 *************** *** 64,69 **** private int generationCounter; ! private double averageRandomFitness; ! private double standardDeviationOfRandomFitness; #endregion --- 64,69 ---- private int generationCounter; ! // private double averageRandomFitness; ! // private double standardDeviationOfRandomFitness; #endregion *************** *** 134,153 **** } ! /// <summary> ! /// Average fitness of a group of genomes (this.numberOfGenomesForAverageRandomFitness) ! /// chosen at random ! /// </summary> ! public double AverageRandomFitness ! { ! get{return this.averageRandomFitness;} ! } ! /// <summary> ! /// Standard deviation of fitness of a group of genomes (this.numberOfGenomesForAverageRandomFitness) ! /// chosen at random ! /// </summary> ! public double StandardDeviationOfRandomFitness ! { ! get{return this.standardDeviationOfRandomFitness;} ! } #endregion --- 134,153 ---- } ! // /// <summary> ! // /// Average fitness of a group of genomes (this.numberOfGenomesForAverageRandomFitness) ! // /// chosen at random ! // /// </summary> ! // public double AverageRandomFitness ! // { ! // get{return this.averageRandomFitness;} ! // } ! // /// <summary> ! // /// Standard deviation of fitness of a group of genomes (this.numberOfGenomesForAverageRandomFitness) ! // /// chosen at random ! // /// </summary> ! // public double StandardDeviationOfRandomFitness ! // { ! // get{return this.standardDeviationOfRandomFitness;} ! // } #endregion *************** *** 220,255 **** } ! /// <summary> ! /// It updates AverageRandomFitness and StandardDeviationOfRandomFitness ! /// properties with the average and std dev fitness ! /// of a given group of genomes chosen at random ! /// </summary> ! public void CalculateRandomFitness() ! { ! this.createFirstGeneration(false); ! this.averageRandomFitness = this.totalSpecialFitnessForRouletteSelection/this.currentGeneration.Count; ! this.standardDeviationOfRandomFitness = this.calculateRandomFitness_getStdDevOfRandomFitness(); ! } ! /// <summary> ! /// It updates StandardDeviationOfRandomFitness property with the std dev of ! /// fitness of a given group of genomes chosen at random ! /// </summary> ! private double calculateRandomFitness_getStdDevOfRandomFitness() ! { ! double[] fitnesses = new double[this.currentGeneration.Count]; ! for(int i = 0; i<this.currentGeneration.Count; i++) ! fitnesses[i] = ((Genome)this.currentGeneration[i]).Fitness; ! return QuantProject.ADT.Statistics.BasicFunctions.StdDev(fitnesses); ! } ! private void run_calculateRandomFitness() ! { ! GeneticOptimizer GOForAverageRandomFitness = ! new GeneticOptimizer(this.genomeManager, ConstantsProvider.NumGenomesForRandomFitnessComputation, ! 0,ConstantsProvider.SeedForRandomGenerator); ! GOForAverageRandomFitness.CalculateRandomFitness(); ! this.averageRandomFitness = GOForAverageRandomFitness.AverageRandomFitness; ! this.standardDeviationOfRandomFitness = GOForAverageRandomFitness.StandardDeviationOfRandomFitness; ! } /// <summary> /// Method to start the GeneticOptmizer --- 220,255 ---- } ! // /// <summary> ! // /// It updates AverageRandomFitness and StandardDeviationOfRandomFitness ! // /// properties with the average and std dev fitness ! // /// of a given group of genomes chosen at random ! // /// </summary> ! // public void CalculateRandomFitness() ! // { ! // this.createFirstGeneration(false); ! // this.averageRandomFitness = this.totalSpecialFitnessForRouletteSelection/this.currentGeneration.Count; ! // this.standardDeviationOfRandomFitness = this.calculateRandomFitness_getStdDevOfRandomFitness(); ! // } ! // /// <summary> ! // /// It updates StandardDeviationOfRandomFitness property with the std dev of ! // /// fitness of a given group of genomes chosen at random ! // /// </summary> ! // private double calculateRandomFitness_getStdDevOfRandomFitness() ! // { ! // double[] fitnesses = new double[this.currentGeneration.Count]; ! // for(int i = 0; i<this.currentGeneration.Count; i++) ! // fitnesses[i] = ((Genome)this.currentGeneration[i]).Fitness; ! // return QuantProject.ADT.Statistics.BasicFunctions.StdDev(fitnesses); ! // } ! // private void run_calculateRandomFitness() ! // { ! // GeneticOptimizer GOForAverageRandomFitness = ! // new GeneticOptimizer(this.genomeManager, ConstantsProvider.NumGenomesForRandomFitnessComputation, ! // 0,ConstantsProvider.SeedForRandomGenerator); ! // GOForAverageRandomFitness.CalculateRandomFitness(); ! // this.averageRandomFitness = GOForAverageRandomFitness.AverageRandomFitness; ! // this.standardDeviationOfRandomFitness = GOForAverageRandomFitness.StandardDeviationOfRandomFitness; ! // } /// <summary> /// Method to start the GeneticOptmizer |
|
From: Marco M. <mi...@us...> - 2009-08-30 15:43:47
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Histories In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv22020/b1_ADT/Histories Modified Files: History.cs Log Message: Fixed minor bug Index: History.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Histories/History.cs,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** History.cs 20 Nov 2008 20:36:30 -0000 1.16 --- History.cs 30 Aug 2009 15:43:36 -0000 1.17 *************** *** 471,475 **** List<DateTime> dateTimes = new List<DateTime>(); ! foreach ( DateTime dateTime in this.Keys ) dateTimes.Add( dateTime ); return dateTimes; --- 471,475 ---- List<DateTime> dateTimes = new List<DateTime>(); ! foreach ( DateTime dateTime in this.Values ) dateTimes.Add( dateTime ); return dateTimes; |
|
From: Marco M. <mi...@us...> - 2009-08-30 15:42:58
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/InSample In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv21967/b4_Business/a2_Strategies/InSample Modified Files: BruteForceChooser.cs Log Message: no message Index: BruteForceChooser.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/InSample/BruteForceChooser.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** BruteForceChooser.cs 29 Sep 2008 21:14:49 -0000 1.4 --- BruteForceChooser.cs 30 Aug 2009 15:42:44 -0000 1.5 *************** *** 26,29 **** --- 26,30 ---- using QuantProject.ADT.Messaging; using QuantProject.ADT.Optimizing.BruteForce; + using QuantProject.ADT.Statistics.Combinatorial; using QuantProject.Business.DataProviders; using QuantProject.Business.Strategies.Eligibles; *************** *** 74,78 **** // this.historicalQuoteProvider = historicalQuoteProvider; } ! protected abstract IBruteForceOptimizableParametersManager getBruteForceOptimizableParametersManager( EligibleTickers eligibleTickers , --- 75,79 ---- // this.historicalQuoteProvider = historicalQuoteProvider; } ! protected abstract IBruteForceOptimizableParametersManager getBruteForceOptimizableParametersManager( EligibleTickers eligibleTickers , |
|
From: Marco M. <mi...@us...> - 2009-08-30 15:42:44
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Optimizing/GenomeManagers In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv21934/b4_Business/a2_Strategies/Optimizing/GenomeManagers Modified Files: BasicGenomeManager.cs Log Message: no message Index: BasicGenomeManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Optimizing/GenomeManagers/BasicGenomeManager.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BasicGenomeManager.cs 19 Feb 2008 21:56:24 -0000 1.2 --- BasicGenomeManager.cs 30 Aug 2009 15:42:32 -0000 1.3 *************** *** 29,32 **** --- 29,33 ---- using QuantProject.Business.Strategies.Optimizing.FitnessEvaluation; + namespace QuantProject.Business.Strategies.Optimizing.GenomeManagers { *************** *** 101,109 **** } } ! public virtual double GetFitnessValue(Genome genome) { ! double fitnessValue = ! this.fitnessEvaluator.GetFitnessValue(genome.Meaning, this.returnsManager); return fitnessValue; } --- 102,111 ---- } } ! public virtual double GetFitnessValue(Genome genome) { ! double fitnessValue = ! this.fitnessEvaluator.GetFitnessValue(genome.Meaning, this.returnsManager); ! return fitnessValue; } |
|
From: Marco M. <mi...@us...> - 2009-08-30 15:42:31
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv21865/b4_Business/a2_Strategies Modified Files: AccountManager.cs Log Message: Added overload for OpenPositions method, in order to use leverage Index: AccountManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/AccountManager.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** AccountManager.cs 13 Dec 2008 17:15:35 -0000 1.7 --- AccountManager.cs 30 Aug 2009 15:42:18 -0000 1.8 *************** *** 93,96 **** --- 93,112 ---- Account account, double initialCashIfTheAccountIsEmpty) { + OpenPositions(weightedPositions, account, initialCashIfTheAccountIsEmpty, 1); + } + + /// <summary> + /// Modifies the state for the given account, + /// opening positions provided by the given weightedPositions + /// </summary> + /// <param name="weightedPositions"></param> + /// <param name="account"></param> + /// <param name="initialCashForTheAccount">The initial cash for the account + /// <param name="leverage">It multiplies initial cash in order to compute + /// value to invest in the given weighted positions</param> + static public void OpenPositions(WeightedPositions weightedPositions, + Account account, double initialCashIfTheAccountIsEmpty, + double leverage) + { if(account.Transactions.Count == 0) account.AddCash(initialCashIfTheAccountIsEmpty); *************** *** 98,102 **** throw new Exception("Both parameters have to be set to valid objects!"); orders.Clear(); ! double valueToInvestInPositions = account.CashAmount; foreach(WeightedPosition weightedPosition in weightedPositions.Values) addWeightedPositionToOrderList( weightedPosition, account, valueToInvestInPositions ); --- 114,118 ---- throw new Exception("Both parameters have to be set to valid objects!"); orders.Clear(); ! double valueToInvestInPositions = account.CashAmount * leverage; foreach(WeightedPosition weightedPosition in weightedPositions.Values) addWeightedPositionToOrderList( weightedPosition, account, valueToInvestInPositions ); |
|
From: Marco M. <mi...@us...> - 2009-08-30 15:41:53
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/StatisticsSummaryRows In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv21738/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/StatisticsSummaryRows Modified Files: AverageReturnOnDayWithOpenPositions.cs Log Message: Fixed minor bug Index: AverageReturnOnDayWithOpenPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/StatisticsSummaryRows/AverageReturnOnDayWithOpenPositions.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AverageReturnOnDayWithOpenPositions.cs 29 Sep 2008 21:13:46 -0000 1.2 --- AverageReturnOnDayWithOpenPositions.cs 30 Aug 2009 15:41:40 -0000 1.3 *************** *** 113,118 **** } } ! this.rowValue = this.getRowValue( totalNumberOfDaysWithOpenPositions , sumOfReturnsOnDaysWithOpenPositions); } } --- 113,121 ---- } } ! this.rowValue= "-"; ! try{ ! this.rowValue = this.getRowValue( totalNumberOfDaysWithOpenPositions , sumOfReturnsOnDaysWithOpenPositions); + }catch{}; } } |
|
From: Glauco S. <gla...@us...> - 2009-08-22 15:57:26
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/InSample/InSampleChoosers/BruteForce In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30022/b7_Scripts/WalkForwardTesting/PairsTrading/InSample/InSampleChoosers/BruteForce Modified Files: PairsTradingBruteForceOptimizableParametersManager.cs Log Message: Buggy comments have been patched Index: PairsTradingBruteForceOptimizableParametersManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/InSample/InSampleChoosers/BruteForce/PairsTradingBruteForceOptimizableParametersManager.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PairsTradingBruteForceOptimizableParametersManager.cs 29 Sep 2008 21:20:45 -0000 1.5 --- PairsTradingBruteForceOptimizableParametersManager.cs 22 Aug 2009 15:57:15 -0000 1.6 *************** *** 36,43 **** /// BruteForceOptimizableParametersManager to be used by the pairs /// trading strategy. ! /// Two TestingPositions are considered equivalent as TopBestPositions ! /// (and only one is kept among them) iif they have the same tickers ! /// (consider that if two WeightedPosition are highly correlated, the ! /// two opposite WeightedPosition are highly correlated too) /// </summary> [Serializable] --- 36,47 ---- /// BruteForceOptimizableParametersManager to be used by the pairs /// trading strategy. ! /// Two TestingPositions are considered equivalent as TopBestParameters ! /// (and only one is kept among them) iif they have the same tickers and ! /// the same fitness. ! /// This is a short way to say that, with respect to the ! /// pairs trading strategy, (a,b) is equivalent to ! /// (-a,-b), and that (a,-b) is equivalent to (-a,b) ! /// We use fitness similarity instead of checking for all possible long/short ! /// combinations /// </summary> [Serializable] *************** *** 102,111 **** return haveTheSameFitness; } ! /// Two TestingPositions are considered equivalent as TopBestPositions ! /// (and only one is kept among them) iif they have the same tickers ! /// (consider that if two WeightedPosition are highly correlated, the ! /// two opposite WeightedPosition are highly correlated too) or ! /// if they have the same fitness (in this second case, probably ! /// two tickers represent the same security and thus are equivalent) public override bool AreEquivalentAsTopBestParameters( BruteForceOptimizableParameters bruteForceOptimizableParameters1 , --- 106,117 ---- return haveTheSameFitness; } ! /// Two TestingPositions are considered equivalent as TopBestParameters ! /// (and only one is kept among them) iif they have the same tickers and ! /// the same fitness. ! /// This is a short way to say that, with respect to the ! /// pairs trading strategy, (a,b) is equivalent to ! /// (-a,-b), and that (a,-b) is equivalent to (-a,b) ! /// We use fitness similarity instead of checking for all possible long/short ! /// combinations public override bool AreEquivalentAsTopBestParameters( BruteForceOptimizableParameters bruteForceOptimizableParameters1 , |
|
From: Marco M. <mi...@us...> - 2009-08-04 21:57:49
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv7626/b2_DataAccess/Tables Modified Files: Quotes.cs Log Message: Some bugs have been fixed Index: Quotes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables/Quotes.cs,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** Quotes.cs 1 Jan 2009 13:42:36 -0000 1.36 --- Quotes.cs 4 Aug 2009 21:57:32 -0000 1.37 *************** *** 504,508 **** { string sql = "SELECT TOP " + maxNumOfReturnedTickers + " tickers.tiTicker, tickers.tiCompanyName, " + ! "StDev(quotes.quAdjustedCloseToCloseRatio) AS AdjCloseToCloseStandDev " + "FROM quotes INNER JOIN (tickers INNER JOIN tickers_tickerGroups " + "ON tickers.tiTicker = tickers_tickerGroups.ttTiId) " + --- 504,509 ---- { string sql = "SELECT TOP " + maxNumOfReturnedTickers + " tickers.tiTicker, tickers.tiCompanyName, " + ! SQLBuilder.GetStandardDeviationFunctionName() + ! "(quotes.quAdjustedCloseToCloseRatio) AS AdjCloseToCloseStandDev " + "FROM quotes INNER JOIN (tickers INNER JOIN tickers_tickerGroups " + "ON tickers.tiTicker = tickers_tickerGroups.ttTiId) " + *************** *** 513,517 **** SQLBuilder.GetDateConstant(lastQuoteDate) + "GROUP BY tickers.tiTicker, tickers.tiCompanyName " + ! "ORDER BY StDev(quotes.quAdjustedCloseToCloseRatio)"; string sortDirection = " DESC"; if(orderInASCMode) --- 514,520 ---- SQLBuilder.GetDateConstant(lastQuoteDate) + "GROUP BY tickers.tiTicker, tickers.tiCompanyName " + ! "ORDER BY " + ! SQLBuilder.GetStandardDeviationFunctionName() + ! "(quotes.quAdjustedCloseToCloseRatio)"; string sortDirection = " DESC"; if(orderInASCMode) *************** *** 530,534 **** { string sql = "SELECT TOP " + maxNumOfReturnedTickers + " tickers.tiTicker, tickers.tiCompanyName, " + ! "StDev(quotes.quClose/quotes.quOpen - 1) AS OpenToCloseStandDev " + "FROM quotes INNER JOIN (tickers INNER JOIN tickers_tickerGroups " + "ON tickers.tiTicker = tickers_tickerGroups.ttTiId) " + --- 533,538 ---- { string sql = "SELECT TOP " + maxNumOfReturnedTickers + " tickers.tiTicker, tickers.tiCompanyName, " + ! SQLBuilder.GetStandardDeviationFunctionName() + ! "(quotes.quClose/quotes.quOpen - 1) AS OpenToCloseStandDev " + "FROM quotes INNER JOIN (tickers INNER JOIN tickers_tickerGroups " + "ON tickers.tiTicker = tickers_tickerGroups.ttTiId) " + *************** *** 539,543 **** SQLBuilder.GetDateConstant(lastQuoteDate) + "GROUP BY tickers.tiTicker, tickers.tiCompanyName " + ! "ORDER BY StDev(quotes.quClose/quotes.quOpen - 1)"; string sortDirection = " DESC"; if(orderInASCMode) --- 543,549 ---- SQLBuilder.GetDateConstant(lastQuoteDate) + "GROUP BY tickers.tiTicker, tickers.tiCompanyName " + ! "ORDER BY " + ! SQLBuilder.GetStandardDeviationFunctionName() + ! "(quotes.quClose/quotes.quOpen - 1)"; string sortDirection = " DESC"; if(orderInASCMode) *************** *** 640,644 **** { string sql = "SELECT TOP " + maxNumOfReturnedTickers + " quotes.quTicker, tickers.tiCompanyName, " + ! "Avg(quotes.quOpen) AS AverageRawOpenPrice, StDev(quotes.quOpen) AS StdDevRawOpenPrice " + "FROM (quotes INNER JOIN tickers ON quotes.quTicker=tickers.tiTicker) " + "INNER JOIN tickers_tickerGroups ON tickers.tiTicker=tickers_tickerGroups.ttTiId " + --- 646,652 ---- { string sql = "SELECT TOP " + maxNumOfReturnedTickers + " quotes.quTicker, tickers.tiCompanyName, " + ! "Avg(quotes.quOpen) AS AverageRawOpenPrice, " + ! SQLBuilder.GetStandardDeviationFunctionName() + ! "(quotes.quOpen) AS StdDevRawOpenPrice " + "FROM (quotes INNER JOIN tickers ON quotes.quTicker=tickers.tiTicker) " + "INNER JOIN tickers_tickerGroups ON tickers.tiTicker=tickers_tickerGroups.ttTiId " + *************** *** 648,652 **** "GROUP BY quotes.quTicker, tickers.tiCompanyName " + "HAVING Avg(quotes.quOpen) BETWEEN " + minPrice + " AND " + maxPrice + " " + ! "AND StDev(quotes.quOpen) BETWEEN " + minStdDeviation + " AND " + maxStdDeviation + " " + "ORDER BY Avg(quotes.quOpen)"; string sortDirection = " DESC"; --- 656,662 ---- "GROUP BY quotes.quTicker, tickers.tiCompanyName " + "HAVING Avg(quotes.quOpen) BETWEEN " + minPrice + " AND " + maxPrice + " " + ! "AND " + ! SQLBuilder.GetStandardDeviationFunctionName() + ! "(quotes.quOpen) BETWEEN " + minStdDeviation + " AND " + maxStdDeviation + " " + "ORDER BY Avg(quotes.quOpen)"; string sortDirection = " DESC"; *************** *** 788,792 **** DataTable dt; string sql = "SELECT quotes.quTicker, " + ! "StDev(quotes.quAdjustedCloseToCloseRatio) AS AdjCloseToCloseStandDev " + "FROM quotes WHERE quTicker ='" + ticker + "' " + --- 798,803 ---- DataTable dt; string sql = "SELECT quotes.quTicker, " + ! SQLBuilder.GetStandardDeviationFunctionName() + ! "(quotes.quAdjustedCloseToCloseRatio) AS AdjCloseToCloseStandDev " + "FROM quotes WHERE quTicker ='" + ticker + "' " + *************** *** 843,847 **** DataTable dt; string sql = "SELECT quotes.quTicker, " + ! "StDev(quotes.quClose/quotes.quOpen) AS CloseToOpenStandDev " + "FROM quotes WHERE quTicker ='" + ticker + "' " + --- 854,859 ---- DataTable dt; string sql = "SELECT quotes.quTicker, " + ! SQLBuilder.GetStandardDeviationFunctionName() + ! "(quotes.quClose/quotes.quOpen) AS CloseToOpenStandDev " + "FROM quotes WHERE quTicker ='" + ticker + "' " + |
|
From: Glauco S. <gla...@us...> - 2009-06-28 17:07:46
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv24013/b7_Scripts/WalkForwardTesting/PairsTrading Modified Files: PairsTradingMain.cs Log Message: some script's parameters have been changed Index: PairsTradingMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/PairsTradingMain.cs,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** PairsTradingMain.cs 15 May 2009 21:41:37 -0000 1.31 --- PairsTradingMain.cs 28 Jun 2009 17:07:37 -0000 1.32 *************** *** 268,272 **** IInefficiencyCorrectionDetector inefficiencyCorrectionDetector = new ConsecutiveMinutesOfCorrectionDetector( ! this.historicalMarketValueProviderForChosingPositionsOutOfSample , 4 ); outOfSampleChooser = new OutOfSampleChooserForAlreadyClosing( --- 268,273 ---- IInefficiencyCorrectionDetector inefficiencyCorrectionDetector = new ConsecutiveMinutesOfCorrectionDetector( ! this.historicalMarketValueProviderForChosingPositionsOutOfSample , 2 ); ! // this.historicalMarketValueProviderForChosingPositionsOutOfSample , 4 ); outOfSampleChooser = new OutOfSampleChooserForAlreadyClosing( *************** *** 328,332 **** firstDateTime = new DateTime( 2006 , 1 , 2 ); // lastDateTime = new DateTime( 2007 , 12 , 31 ); ! lastDateTime = new DateTime( 2006 , 12 , 31 ); double maxRunningHours = 11; --- 329,333 ---- firstDateTime = new DateTime( 2006 , 1 , 2 ); // lastDateTime = new DateTime( 2007 , 12 , 31 ); ! lastDateTime = new DateTime( 2006 , 1 , 10 ); double maxRunningHours = 11; |
|
From: Marco M. <mi...@us...> - 2009-05-15 21:41:44
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18829/b4_Business/a07_DataProviders Modified Files: HistoricalMarketValueProviderWithQuoteBackupOnClose.cs Log Message: The constructor has been modified: now the HistoricalMarketValueProvider used as the back up has to be passed as a parameter Index: HistoricalMarketValueProviderWithQuoteBackupOnClose.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders/HistoricalMarketValueProviderWithQuoteBackupOnClose.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HistoricalMarketValueProviderWithQuoteBackupOnClose.cs 28 Feb 2009 18:14:57 -0000 1.1 --- HistoricalMarketValueProviderWithQuoteBackupOnClose.cs 15 May 2009 21:41:37 -0000 1.2 *************** *** 38,52 **** { private HistoricalMarketValueProvider historicalMarketValueProvider; ! ! private HistoricalRawQuoteProvider historicalRawQuoteProvider; public HistoricalMarketValueProviderWithQuoteBackupOnClose( ! HistoricalMarketValueProvider historicalMarketValueProvider ) { this.historicalMarketValueProvider = historicalMarketValueProvider; ! ! this.historicalRawQuoteProvider = new HistoricalRawQuoteProvider(); } - protected override string getDescription() { --- 38,51 ---- { private HistoricalMarketValueProvider historicalMarketValueProvider; ! ! private HistoricalQuoteProvider historicalQuoteProvider; public HistoricalMarketValueProviderWithQuoteBackupOnClose( ! HistoricalMarketValueProvider historicalMarketValueProvider, ! HistoricalQuoteProvider historicalQuoteProviderBackUp) { this.historicalMarketValueProvider = historicalMarketValueProvider; ! this.historicalQuoteProvider = historicalQuoteProviderBackUp; } protected override string getDescription() { *************** *** 57,66 **** #region GetMarketValue ! private double getRawCloseIfTheCase( string ticker , DateTime dateTime ) { double marketValue = double.NaN; if ( HistoricalEndOfDayTimer.IsMarketClose( dateTime ) ) // dateTime is at market close ! marketValue = this.historicalRawQuoteProvider.GetMarketValue( ticker , dateTime ); else --- 56,65 ---- #region GetMarketValue ! private double getCloseIfTheCase( string ticker , DateTime dateTime ) { double marketValue = double.NaN; if ( HistoricalEndOfDayTimer.IsMarketClose( dateTime ) ) // dateTime is at market close ! marketValue = this.historicalQuoteProvider.GetMarketValue( ticker , dateTime ); else *************** *** 78,82 **** // this.historicalMarketValueProvider doesn't have a market value for // the given ticker, at the given dateTime ! marketValue = this.getRawCloseIfTheCase( ticker , dateTime ); return marketValue; } --- 77,81 ---- // this.historicalMarketValueProvider doesn't have a market value for // the given ticker, at the given dateTime ! marketValue = this.getCloseIfTheCase( ticker , dateTime ); return marketValue; } *************** *** 86,94 **** #region WasExchanged ! private bool isRawCloseAnAvailableBackup( string ticker , DateTime dateTime ) { bool isBackupAvailable = HistoricalEndOfDayTimer.IsMarketClose( dateTime ); isBackupAvailable = isBackupAvailable && ! this.historicalRawQuoteProvider.WasExchanged( ticker , dateTime ); return isBackupAvailable; } --- 85,93 ---- #region WasExchanged ! private bool isCloseAnAvailableBackup( string ticker , DateTime dateTime ) { bool isBackupAvailable = HistoricalEndOfDayTimer.IsMarketClose( dateTime ); isBackupAvailable = isBackupAvailable && ! this.historicalQuoteProvider.WasExchanged( ticker , dateTime ); return isBackupAvailable; } *************** *** 98,102 **** ticker , dateTime ); wasExchanged = wasExchanged || ! this.isRawCloseAnAvailableBackup( ticker , dateTime ); return wasExchanged; } --- 97,101 ---- ticker , dateTime ); wasExchanged = wasExchanged || ! this.isCloseAnAvailableBackup( ticker , dateTime ); return wasExchanged; } |
|
From: Marco M. <mi...@us...> - 2009-05-15 21:41:44
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18829/b7_Scripts/WalkForwardTesting/PairsTrading Modified Files: PairsTradingMain.cs Log Message: The constructor has been modified: now the HistoricalMarketValueProvider used as the back up has to be passed as a parameter Index: PairsTradingMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/PairsTradingMain.cs,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** PairsTradingMain.cs 1 Mar 2009 21:05:43 -0000 1.30 --- PairsTradingMain.cs 15 May 2009 21:41:37 -0000 1.31 *************** *** 152,156 **** historicalMarketValueProviderForTheBacktesterAccount = new HistoricalMarketValueProviderWithQuoteBackupOnClose( ! this.historicalMarketValueProviderForChosingPositionsOutOfSample ); return historicalMarketValueProviderForTheBacktesterAccount; } --- 152,157 ---- historicalMarketValueProviderForTheBacktesterAccount = new HistoricalMarketValueProviderWithQuoteBackupOnClose( ! this.historicalMarketValueProviderForChosingPositionsOutOfSample, ! new HistoricalRawQuoteProvider() ); return historicalMarketValueProviderForTheBacktesterAccount; } |
|
From: Glauco S. <gla...@us...> - 2009-04-21 21:29:42
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18616/b4_Business/a07_DataProviders Modified Files: HistoricalAdjustedBarProvider.cs Log Message: The Serializable attribute has been added Index: HistoricalAdjustedBarProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders/HistoricalAdjustedBarProvider.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HistoricalAdjustedBarProvider.cs 4 Apr 2009 15:48:05 -0000 1.1 --- HistoricalAdjustedBarProvider.cs 21 Apr 2009 21:29:24 -0000 1.2 *************** *** 31,34 **** --- 31,35 ---- /// Returns adjusted historical intraday market values /// </summary> + [Serializable] public class HistoricalAdjustedBarProvider : HistoricalMarketValueProvider { |
|
From: Glauco S. <gla...@us...> - 2009-04-04 15:48:46
|
Update of /cvsroot/quantproject/QuantProject/b4_Business In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13522/b4_Business Modified Files: Business_SD.csproj Log Message: a07_DataProviders\HistoricalAdjustedBarProvider.cs has been added Index: Business_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/Business_SD.csproj,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** Business_SD.csproj 21 Mar 2009 09:56:21 -0000 1.38 --- Business_SD.csproj 4 Apr 2009 15:48:28 -0000 1.39 *************** *** 48,51 **** --- 48,52 ---- <Compile Include="a05_Timing\IndexBasedHistoricalTimer.cs" /> <Compile Include="a05_Timing\Timer.cs" /> + <Compile Include="a07_DataProviders\HistoricalAdjustedBarProvider.cs" /> <Compile Include="a07_DataProviders\HistoricalBarInterpolatingProvider.cs" /> <Compile Include="a07_DataProviders\HistoricalMarketValueProviderWithQuoteBackupOnClose.cs" /> |
|
From: Glauco S. <gla...@us...> - 2009-04-04 15:48:23
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13461/b4_Business/a07_DataProviders Added Files: HistoricalAdjustedBarProvider.cs Log Message: Returns adjusted historical intraday market values --- NEW FILE: HistoricalAdjustedBarProvider.cs --- /* QuantProject - Quantitative Finance Library HistoricalAdjustedBarProvider.cs Copyright (C) 2009 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; using QuantProject.Business.Timing; using QuantProject.Data.DataProviders.Bars; namespace QuantProject.Business.DataProviders { /// <summary> /// Returns adjusted historical intraday market values /// </summary> public class HistoricalAdjustedBarProvider : HistoricalMarketValueProvider { private HistoricalBarProvider historicalBarProvider; private HistoricalRawQuoteProvider historicalRawQuoteProvider; private HistoricalAdjustedQuoteProvider historicalAdjustedQuoteProvider; public HistoricalAdjustedBarProvider( HistoricalBarProvider historicalBarProvider , HistoricalRawQuoteProvider historicalRawQuoteProvider , HistoricalAdjustedQuoteProvider historicalAdjustedQuoteProvider ) { this.historicalBarProvider = historicalBarProvider; this.historicalRawQuoteProvider = historicalRawQuoteProvider; this.historicalAdjustedQuoteProvider = historicalAdjustedQuoteProvider; } protected override string getDescription() { return "adjustedBarProvider"; } #region GetMarketValue private double getAdjustmenFactor( string ticker , DateTime dateTime ) { DateTime marketCloseDateTime = HistoricalEndOfDayTimer.GetMarketClose( dateTime ); double rawClose = this.historicalRawQuoteProvider.GetMarketValue( ticker , marketCloseDateTime ); double adjustedClose = this.historicalAdjustedQuoteProvider.GetMarketValue( ticker , marketCloseDateTime ); double adjustmentFactor = adjustedClose / rawClose; return adjustmentFactor; } public override double GetMarketValue( string ticker , DateTime dateTime ) { double adjustmentFactor = this.getAdjustmenFactor( ticker , dateTime ); double marketValue = double.NaN; try { marketValue = this.historicalBarProvider.GetMarketValue( ticker , dateTime ) * adjustmentFactor; } catch( MissingBarException missingBarException ) { string forBreakPoint = missingBarException.Message; forBreakPoint += " "; throw new TickerNotExchangedException( ticker , dateTime ); } return marketValue; } #endregion GetMarketValue public override bool WasExchanged( string ticker, DateTime dateTime ) { bool wasExchanged = this.historicalBarProvider.WasExchanged( ticker , dateTime ); return wasExchanged; } } } |
|
From: Marco M. <mi...@us...> - 2009-03-30 21:37:26
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv7642/b7_Scripts/WalkForwardTesting/PairsTrading/Logging Modified Files: PairsTradingSerializedReportViewer.cs Log Message: Added a new constructor to PairsTradingSerializedReportViewer. Index: PairsTradingSerializedReportViewer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging/PairsTradingSerializedReportViewer.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PairsTradingSerializedReportViewer.cs 7 Mar 2009 04:20:04 -0000 1.1 --- PairsTradingSerializedReportViewer.cs 30 Mar 2009 21:37:18 -0000 1.2 *************** *** 43,49 **** --- 43,56 ---- private string fullPathFileNameForSerializedAccountReport; private AccountReport accountReport; + private QuantProject.Business.DataProviders.HistoricalMarketValueProvider historicalMarketValueProvider; public PairsTradingSerializedReportViewer() { + this.historicalMarketValueProvider = + new HistoricalBarProvider( new SimpleBarCache( 60 ) ); + } + public PairsTradingSerializedReportViewer(HistoricalMarketValueProvider historicalMarketValueProvider) + { + this.historicalMarketValueProvider = historicalMarketValueProvider; } *************** *** 211,215 **** WeightedPosition secondWeightedPosition = new WeightedPosition( 0.5 , secondTicker ); PairsViewer pairsViewer = new PairsViewer( ! new HistoricalBarProvider( new SimpleBarCache( 60 ) ) , firstWeightedPosition , secondWeightedPosition , clickedDateTime ); pairsViewer.Show(); --- 218,222 ---- WeightedPosition secondWeightedPosition = new WeightedPosition( 0.5 , secondTicker ); PairsViewer pairsViewer = new PairsViewer( ! this.historicalMarketValueProvider , firstWeightedPosition , secondWeightedPosition , clickedDateTime ); pairsViewer.Show(); |
|
From: Marco M. <mi...@us...> - 2009-03-30 21:35:29
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv7457/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables Modified Files: RoundTrades.cs Log Message: Fixed some minor bugs (now round trades statistics are properly computed). Index: RoundTrades.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables/RoundTrades.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RoundTrades.cs 29 Mar 2009 18:15:50 -0000 1.3 --- RoundTrades.cs 30 Mar 2009 21:35:23 -0000 1.4 *************** *** 1,4 **** --- 1,6 ---- using System; using System.Data; + + using QuantProject.ADT; using QuantProject.Business.Financial.Accounting.Reporting; *************** *** 82,86 **** DataRow roundTrade = roundTradeDataTable.NewRow(); roundTrade[ fieldNameForTicker ] = currentTicker; ! roundTrade[ "Trade" ] = currentTradeType; roundTrade[ "Quantity" ] = instrumentQuantity; roundTrade[ "EntryDate" ] = startDateTimeOfTrade; --- 84,91 ---- DataRow roundTrade = roundTradeDataTable.NewRow(); roundTrade[ fieldNameForTicker ] = currentTicker; ! if ( currentTradeType == "BuyLong" ) ! roundTrade[ "Trade" ] = "Long"; ! else ! roundTrade[ "Trade" ] = "Short"; roundTrade[ "Quantity" ] = instrumentQuantity; roundTrade[ "EntryDate" ] = startDateTimeOfTrade; *************** *** 117,121 **** getRoundTradeTable_setColumns( roundTradeDataTable ); getRoundTradeTable_setRows( roundTradeDataTable ); ! return roundTradeDataTable; } #endregion --- 122,128 ---- getRoundTradeTable_setColumns( roundTradeDataTable ); getRoundTradeTable_setRows( roundTradeDataTable ); ! DataTable roundTradeDataTable_ordered = ! ExtendedDataTable.CopyAndSort(roundTradeDataTable, "EntryDate", true); ! return roundTradeDataTable_ordered; } #endregion |
|
From: Marco M. <mi...@us...> - 2009-03-29 18:35:48
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/Selectors In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4337/b3_Data/Selectors Modified Files: SelectorByLiquidity.cs Log Message: Added the new parameter numOfTopRowsToDelete to the SelectorByLiquidity: now it is possible to select not only the most or the less liquid tickers, but also tickers with a medium liquidity (by setting the number of top rows, that is the less or most liquid tickers, that have to be deleted from the resulting table, leaving only the desired n tickers) Index: SelectorByLiquidity.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/Selectors/SelectorByLiquidity.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SelectorByLiquidity.cs 17 Sep 2006 21:36:09 -0000 1.3 --- SelectorByLiquidity.cs 29 Mar 2009 18:35:36 -0000 1.4 *************** *** 35,99 **** public class SelectorByLiquidity : TickerSelector, ITickerSelector { ! private long minVolume = long.MinValue; ! public SelectorByLiquidity(DataTable setOfTickersToBeSelected, bool orderInASCmode, DateTime firstQuoteDate, DateTime lastQuoteDate, long maxNumOfReturnedTickers): ! base(setOfTickersToBeSelected, ! orderInASCmode, ! firstQuoteDate, ! lastQuoteDate, ! maxNumOfReturnedTickers) { ! } ! public SelectorByLiquidity(DataTable setOfTickersToBeSelected, ! bool orderInASCmode, ! DateTime firstQuoteDate, ! DateTime lastQuoteDate, ! long minVolume, ! long maxNumOfReturnedTickers): ! base(setOfTickersToBeSelected, ! orderInASCmode, ! firstQuoteDate, ! lastQuoteDate, ! maxNumOfReturnedTickers) ! { ! this.minVolume = minVolume; ! } ! ! public SelectorByLiquidity(string groupID, ! bool orderInASCmode, ! DateTime firstQuoteDate, ! DateTime lastQuoteDate, ! long maxNumOfReturnedTickers): ! base(groupID, ! orderInASCmode, ! firstQuoteDate, ! lastQuoteDate, ! maxNumOfReturnedTickers) ! { ! ! } ! ! public SelectorByLiquidity(string groupID, ! bool orderInASCmode, ! DateTime firstQuoteDate, ! DateTime lastQuoteDate, ! long minVolume , ! long maxNumOfReturnedTickers ): ! base(groupID, ! orderInASCmode, ! firstQuoteDate, ! lastQuoteDate, ! maxNumOfReturnedTickers) ! { ! this.minVolume = minVolume; ! } ! ! public DataTable GetTableOfSelectedTickers() { --- 35,202 ---- public class SelectorByLiquidity : TickerSelector, ITickerSelector { ! private long minVolume; ! private long numberOfTopRowsToDelete; + #region SelectorByLiquidity Constructors + + private void selectorByLiquidity_checkParameters(DataTable setOfTickersToBeSelected, + long maxNumOfReturnedTickers, + long numberOfTopRowsToDelete) + { + if( (int)maxNumOfReturnedTickers+(int)numberOfTopRowsToDelete > + setOfTickersToBeSelected.Rows.Count ) + throw new Exception("parameters maxNumOfReturnedTickers=" + maxNumOfReturnedTickers.ToString() + + " and numberOfTopRowsToDelete=" + numberOfTopRowsToDelete.ToString() + + " are too high " + + "for the given setOfTickersToBeSelected (num of rows: " + + setOfTickersToBeSelected.Rows.Count.ToString() + ")"); + } + + /// <summary> + /// ITickerSelector class for selecting tickers + /// by liquidity + /// </summary> + /// <param name="setOfTickersToBeSelected">DataTable containing + /// tickers that have to be selected</param> + /// <param name="orderInASCmode">If true, returned tickers + /// are ordered in Ascending mode - from less to most. If false + /// , returned tickers are ordered in descending mode - from most to less</param> + /// <param name="firstQuoteDate"></param> + /// <param name="lastQuoteDate"></param> + /// <param name="maxNumOfReturnedTickers">Max number of selected + /// tickers to be returned</param> + /// <param name="numberOfTopRowsToDelete">Number of top rows that have to be + /// deleted from the returned table. In other words, + /// max number of selected tickers are chosen after skipping the + /// first "numberOfTopRowsToDelete" rows from the tickers' table + /// resulting from selection by liquidity on the given initial + /// set of tickers + /// </param> + /// <returns></returns> public SelectorByLiquidity(DataTable setOfTickersToBeSelected, bool orderInASCmode, DateTime firstQuoteDate, DateTime lastQuoteDate, + long maxNumOfReturnedTickers, + long numberOfTopRowsToDelete): + base(setOfTickersToBeSelected, + orderInASCmode, + firstQuoteDate, + lastQuoteDate, + maxNumOfReturnedTickers) + { + this.selectorByLiquidity_checkParameters(setOfTickersToBeSelected, + maxNumOfReturnedTickers, + numberOfTopRowsToDelete); + this.minVolume = long.MinValue; + this.numberOfTopRowsToDelete = numberOfTopRowsToDelete; + } + /// <summary> + /// ITickerSelector class for selecting tickers + /// by liquidity + /// </summary> + /// <param name="setOfTickersToBeSelected">DataTable containing + /// tickers that have to be selected</param> + /// <param name="orderInASCmode">If true, returned tickers + /// are ordered in Ascending mode - from less to most. If false + /// , returned tickers are ordered in descending mode - from most to less</param> + /// <param name="firstQuoteDate"></param> + /// <param name="lastQuoteDate"></param> + /// <param name="minVolume">Filter by volume: only tickers having + /// average volume >= minVolume in the given period are selected</param> + /// <param name="maxNumOfReturnedTickers">Max number of selected + /// tickers to be returned</param> + /// <param name="numberOfTopRowsToDelete">Number of top rows that have to be + /// deleted from the returned table. In other words, + /// max number of selected tickers are chosen after skipping the + /// first "numberOfTopRowsToDelete" rows from the tickers' table + /// resulting from selection by liquidity on the given initial + /// set of tickers + /// </param> + /// <returns></returns> + public SelectorByLiquidity(DataTable setOfTickersToBeSelected, + bool orderInASCmode, + DateTime firstQuoteDate, + DateTime lastQuoteDate, + long minVolume, + long maxNumOfReturnedTickers, + long numberOfTopRowsToDelete): + base(setOfTickersToBeSelected, + orderInASCmode, + firstQuoteDate, + lastQuoteDate, + maxNumOfReturnedTickers) + { + this.selectorByLiquidity_checkParameters(setOfTickersToBeSelected, + maxNumOfReturnedTickers, + numberOfTopRowsToDelete); + this.minVolume = minVolume; + this.numberOfTopRowsToDelete = numberOfTopRowsToDelete; + } + public SelectorByLiquidity(DataTable setOfTickersToBeSelected, + bool orderInASCmode, + DateTime firstQuoteDate, + DateTime lastQuoteDate, long maxNumOfReturnedTickers): ! base(setOfTickersToBeSelected, ! orderInASCmode, ! firstQuoteDate, ! lastQuoteDate, ! maxNumOfReturnedTickers) { ! this.selectorByLiquidity_checkParameters(setOfTickersToBeSelected, ! maxNumOfReturnedTickers, ! 0); ! this.minVolume = long.MinValue; ! this.numberOfTopRowsToDelete = 0; } ! public SelectorByLiquidity(DataTable setOfTickersToBeSelected, ! bool orderInASCmode, ! long minVolume, ! DateTime firstQuoteDate, ! DateTime lastQuoteDate, ! long maxNumOfReturnedTickers): ! base(setOfTickersToBeSelected, ! orderInASCmode, ! firstQuoteDate, ! lastQuoteDate, ! maxNumOfReturnedTickers) ! { ! this.selectorByLiquidity_checkParameters(setOfTickersToBeSelected, ! maxNumOfReturnedTickers, ! 0); ! this.minVolume = minVolume; ! this.numberOfTopRowsToDelete = 0; ! } ! public SelectorByLiquidity(string groupID, ! bool orderInASCmode, ! DateTime firstQuoteDate, ! DateTime lastQuoteDate, ! long maxNumOfReturnedTickers): ! base(groupID, ! orderInASCmode, ! firstQuoteDate, ! lastQuoteDate, ! maxNumOfReturnedTickers) ! { ! this.minVolume = long.MinValue; ! } ! public SelectorByLiquidity(string groupID, ! bool orderInASCmode, ! DateTime firstQuoteDate, ! DateTime lastQuoteDate, ! long minVolume , ! long maxNumOfReturnedTickers ): ! base(groupID, ! orderInASCmode, ! firstQuoteDate, ! lastQuoteDate, ! maxNumOfReturnedTickers) ! { ! this.minVolume = minVolume; ! } ! ! #endregion SelectorByLiquidityConstructors ! public DataTable GetTableOfSelectedTickers() { *************** *** 130,134 **** this.lastQuoteDate, this.minVolume, ! this.maxNumOfReturnedTickers); else returnTickers = --- 233,238 ---- this.lastQuoteDate, this.minVolume, ! this.maxNumOfReturnedTickers, ! this.numberOfTopRowsToDelete); else returnTickers = *************** *** 137,149 **** this.firstQuoteDate, this.lastQuoteDate, ! this.maxNumOfReturnedTickers); } return returnTickers; } ! public void SelectAllTickers() ! { ! ; ! } ! ! } } --- 241,253 ---- this.firstQuoteDate, this.lastQuoteDate, ! this.maxNumOfReturnedTickers, ! this.numberOfTopRowsToDelete); } return returnTickers; } ! public void SelectAllTickers() ! { ! ; ! } ! } } |
|
From: Marco M. <mi...@us...> - 2009-03-29 18:35:43
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataTables In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4337/b3_Data/DataTables Modified Files: Quotes.cs Log Message: Added the new parameter numOfTopRowsToDelete to the SelectorByLiquidity: now it is possible to select not only the most or the less liquid tickers, but also tickers with a medium liquidity (by setting the number of top rows, that is the less or most liquid tickers, that have to be deleted from the resulting table, leaving only the desired n tickers) Index: Quotes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataTables/Quotes.cs,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** Quotes.cs 30 Dec 2008 00:14:16 -0000 1.38 --- Quotes.cs 29 Mar 2009 18:35:36 -0000 1.39 *************** *** 117,121 **** DateTime firstQuoteDate, DateTime lastQuoteDate, ! long maxNumOfReturnedTickers) { if(!setOfTickers.Columns.Contains("AverageTradedValue")) --- 117,122 ---- DateTime firstQuoteDate, DateTime lastQuoteDate, ! long maxNumOfReturnedTickers, ! long numberOfTopRowsToDelete) { if(!setOfTickers.Columns.Contains("AverageTradedValue")) *************** *** 129,133 **** } DataTable getMostLiquidTicker = ExtendedDataTable.CopyAndSort(setOfTickers,"AverageTradedValue", orderByASC); ! ExtendedDataTable.DeleteRows(getMostLiquidTicker, maxNumOfReturnedTickers); return getMostLiquidTicker; } --- 130,135 ---- } DataTable getMostLiquidTicker = ExtendedDataTable.CopyAndSort(setOfTickers,"AverageTradedValue", orderByASC); ! ExtendedDataTable.DeleteRows(getMostLiquidTicker, maxNumOfReturnedTickers + numberOfTopRowsToDelete); ! ExtendedDataTable.DeleteRows(getMostLiquidTicker, 0, numberOfTopRowsToDelete - 1); return getMostLiquidTicker; } *************** *** 142,146 **** DateTime lastQuoteDate, long minVolume, ! long maxNumOfReturnedTickers) { if(!setOfTickers.Columns.Contains("AverageTradedValue")) --- 144,149 ---- DateTime lastQuoteDate, long minVolume, ! long maxNumOfReturnedTickers, ! long numberOfTopRowsToDelete) { if(!setOfTickers.Columns.Contains("AverageTradedValue")) *************** *** 165,169 **** "AverageTradedValue", orderByASC); ! ExtendedDataTable.DeleteRows(getMostLiquidTicker, maxNumOfReturnedTickers); return getMostLiquidTicker; } --- 168,173 ---- "AverageTradedValue", orderByASC); ! ExtendedDataTable.DeleteRows(getMostLiquidTicker, maxNumOfReturnedTickers + numberOfTopRowsToDelete); ! ExtendedDataTable.DeleteRows(getMostLiquidTicker, 0, numberOfTopRowsToDelete - 1); return getMostLiquidTicker; } |
|
From: Marco M. <mi...@us...> - 2009-03-29 18:35:42
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Eligibles In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4337/b4_Business/a2_Strategies/Eligibles Modified Files: ByPriceMostLiquidAlwaysIntradayQuoted.cs Log Message: Added the new parameter numOfTopRowsToDelete to the SelectorByLiquidity: now it is possible to select not only the most or the less liquid tickers, but also tickers with a medium liquidity (by setting the number of top rows, that is the less or most liquid tickers, that have to be deleted from the resulting table, leaving only the desired n tickers) Index: ByPriceMostLiquidAlwaysIntradayQuoted.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Eligibles/ByPriceMostLiquidAlwaysIntradayQuoted.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ByPriceMostLiquidAlwaysIntradayQuoted.cs 13 Mar 2009 15:17:53 -0000 1.1 --- ByPriceMostLiquidAlwaysIntradayQuoted.cs 29 Mar 2009 18:35:36 -0000 1.2 *************** *** 53,56 **** --- 53,57 ---- private Benchmark benchmark; private int maxNumberOfEligibleTickersToBeChosen; + private int numberOfTopRowsToDeleteFromLiquidSelector; private int numOfDaysForAverageOpenRawPriceComputation; private double minPrice; *************** *** 75,78 **** --- 76,80 ---- bool temporizedGroup, int maxNumberOfEligibleTickersToBeChosen, + int numberOfTopRowsToDeleteFromLiquidSelector, int numOfDaysForAverageOpenRawPriceComputation, double minPrice, double maxPrice, *************** *** 84,87 **** --- 86,91 ---- this.maxNumberOfEligibleTickersToBeChosen = maxNumberOfEligibleTickersToBeChosen; + this.numberOfTopRowsToDeleteFromLiquidSelector = + numberOfTopRowsToDeleteFromLiquidSelector; this.numOfDaysForAverageOpenRawPriceComputation = numOfDaysForAverageOpenRawPriceComputation; *************** *** 119,123 **** new SelectorByLiquidity( dataTableByPrice , false, history.FirstDateTime, currentDate, ! this.maxNumberOfEligibleTickersToBeChosen); DataTable dataTableMostLiquid = mostLiquidSelector.GetTableOfSelectedTickers(); --- 123,128 ---- new SelectorByLiquidity( dataTableByPrice , false, history.FirstDateTime, currentDate, ! this.maxNumberOfEligibleTickersToBeChosen, ! this.numberOfTopRowsToDeleteFromLiquidSelector); DataTable dataTableMostLiquid = mostLiquidSelector.GetTableOfSelectedTickers(); |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3961/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator Modified Files: PVOStrategyIntradayMain.cs PVOPositionsStatus.cs PVOStrategyIntraday.cs Log Message: PVOStrategyIntraday files have been updated. Index: PVOStrategyIntraday.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVOStrategyIntraday.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PVOStrategyIntraday.cs 13 Mar 2009 15:12:01 -0000 1.4 --- PVOStrategyIntraday.cs 29 Mar 2009 18:31:00 -0000 1.5 *************** *** 71,75 **** protected IEligiblesSelector eligiblesSelector; protected Benchmark benchmark; ! protected HistoricalMarketValueProvider historicalMarketValueProviderForInSample; protected HistoricalMarketValueProvider --- 71,75 ---- protected IEligiblesSelector eligiblesSelector; protected Benchmark benchmark; ! protected HistoricalMarketValueProvider historicalMarketValueProviderForInSample; protected HistoricalMarketValueProvider *************** *** 102,105 **** --- 102,106 ---- protected bool takeProfitConditionReached; protected double inefficiencyLengthInMinutes; + protected int numberOfPreviousEfficientPeriods; protected double maxOpeningLengthInMinutes; protected double minutesFromLastInefficiencyTimeToWaitBeforeOpening; *************** *** 113,117 **** protected double stopLoss; protected double takeProfit; ! private string description_GetDescriptionForChooser() { --- 114,118 ---- protected double stopLoss; protected double takeProfit; ! private string description_GetDescriptionForChooser() { *************** *** 162,181 **** private void pvoStrategyIntraday(IEligiblesSelector eligiblesSelector, ! int minimumNumberOfEligiblesForValidOptimization, ! int inSampleDays, ! Benchmark benchmark, ! int numDaysBetweenEachOptimization, ! double oversoldThreshold, ! double overboughtThreshold, ! double oversoldThresholdMAX, ! double overboughtThresholdMAX, ! HistoricalMarketValueProvider historicalMarketValueProviderForInSample, ! HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, ! double inefficiencyLengthInMinutes, ! double minutesFromLastInefficiencyTimeToWaitBeforeOpening, ! double minutesFromLastLossOrProfitToWaitBeforeClosing, ! double maxOpeningLengthInMinutes, ! List<Time> openingTimesForAvailableBars, ! double stopLoss, double takeProfit) { this.eligiblesSelector = eligiblesSelector; --- 163,183 ---- private void pvoStrategyIntraday(IEligiblesSelector eligiblesSelector, ! int minimumNumberOfEligiblesForValidOptimization, ! int inSampleDays, ! Benchmark benchmark, ! int numDaysBetweenEachOptimization, ! double oversoldThreshold, ! double overboughtThreshold, ! double oversoldThresholdMAX, ! double overboughtThresholdMAX, ! HistoricalMarketValueProvider historicalMarketValueProviderForInSample, ! HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, ! double inefficiencyLengthInMinutes, ! int numberOfPreviousEfficientPeriods, ! double minutesFromLastInefficiencyTimeToWaitBeforeOpening, ! double minutesFromLastLossOrProfitToWaitBeforeClosing, ! double maxOpeningLengthInMinutes, ! List<Time> openingTimesForAvailableBars, ! double stopLoss, double takeProfit) { this.eligiblesSelector = eligiblesSelector; *************** *** 192,198 **** this.historicalMarketValueProviderForOutOfSample = historicalMarketValueProviderForOutOfSample; this.inefficiencyLengthInMinutes = inefficiencyLengthInMinutes; ! this.minutesFromLastInefficiencyTimeToWaitBeforeOpening = minutesFromLastInefficiencyTimeToWaitBeforeOpening; ! this.minutesFromLastLossOrProfitToWaitBeforeClosing = minutesFromLastLossOrProfitToWaitBeforeClosing; this.maxOpeningLengthInMinutes = maxOpeningLengthInMinutes; --- 194,201 ---- this.historicalMarketValueProviderForOutOfSample = historicalMarketValueProviderForOutOfSample; this.inefficiencyLengthInMinutes = inefficiencyLengthInMinutes; ! this.numberOfPreviousEfficientPeriods = numberOfPreviousEfficientPeriods; ! this.minutesFromLastInefficiencyTimeToWaitBeforeOpening = minutesFromLastInefficiencyTimeToWaitBeforeOpening; ! this.minutesFromLastLossOrProfitToWaitBeforeClosing = minutesFromLastLossOrProfitToWaitBeforeClosing; this.maxOpeningLengthInMinutes = maxOpeningLengthInMinutes; *************** *** 209,346 **** public PVOStrategyIntraday(IEligiblesSelector eligiblesSelector, ! int minimumNumberOfEligiblesForValidOptimization, ! IInSampleChooser inSampleChooser, ! int inSampleDays, ! Benchmark benchmark, ! int numDaysBetweenEachOptimization, ! double oversoldThreshold, ! double overboughtThreshold, ! double oversoldThresholdMAX, ! double overboughtThresholdMAX, ! HistoricalMarketValueProvider historicalMarketValueProviderForInSample, ! HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, ! double inefficiencyLengthInMinutes, ! double minutesFromLastInefficiencyTimeToWaitBeforeOpening, ! double minutesFromLastLossOrProfitToWaitBeforeClosing, ! double maxOpeningLengthInMinutes, ! List<Time> openingTimesForAvailableBars, ! double stopLoss, double takeProfit) { this.pvoStrategyIntraday(eligiblesSelector, minimumNumberOfEligiblesForValidOptimization, ! inSampleDays , benchmark , numDaysBetweenEachOptimization , ! oversoldThreshold, overboughtThreshold, ! oversoldThresholdMAX, overboughtThresholdMAX, ! historicalMarketValueProviderForInSample, ! historicalMarketValueProviderForOutOfSample, ! inefficiencyLengthInMinutes, ! minutesFromLastInefficiencyTimeToWaitBeforeOpening, ! minutesFromLastLossOrProfitToWaitBeforeClosing, ! maxOpeningLengthInMinutes, ! openingTimesForAvailableBars, ! stopLoss, takeProfit); this.inSampleChooser = inSampleChooser; } public PVOStrategyIntraday(IEligiblesSelector eligiblesSelector, ! int minimumNumberOfEligiblesForValidOptimization, ! IInSampleChooser inSampleChooser, ! int inSampleDays, ! Benchmark benchmark, ! int numDaysBetweenEachOptimization, ! double oversoldThreshold, ! double overboughtThreshold, ! HistoricalMarketValueProvider historicalMarketValueProviderForInSample, ! HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, ! double inefficiencyLengthInMinutes, ! double minutesFromLastInefficiencyTimeToWaitBeforeOpening, ! double minutesFromLastLossOrProfitToWaitBeforeClosing, ! double maxOpeningLengthInMinutes, ! List<Time> openingTimesForAvailableBars, ! double stopLoss, double takeProfit) { this.pvoStrategyIntraday(eligiblesSelector, minimumNumberOfEligiblesForValidOptimization, ! inSampleDays , benchmark , numDaysBetweenEachOptimization , ! oversoldThreshold, overboughtThreshold, ! double.MaxValue, double.MaxValue, ! historicalMarketValueProviderForInSample, ! historicalMarketValueProviderForOutOfSample, ! inefficiencyLengthInMinutes, ! minutesFromLastInefficiencyTimeToWaitBeforeOpening, ! minutesFromLastLossOrProfitToWaitBeforeClosing, ! maxOpeningLengthInMinutes, ! openingTimesForAvailableBars, ! stopLoss, takeProfit); this.inSampleChooser = inSampleChooser; } public PVOStrategyIntraday(IEligiblesSelector eligiblesSelector, ! int minimumNumberOfEligiblesForValidOptimization, ! TestingPositions[] chosenPVOPositions, ! int inSampleDays, ! Benchmark benchmark, ! int numDaysBetweenEachOptimization, ! double oversoldThreshold, ! double overboughtThreshold, ! double oversoldThresholdMAX, ! double overboughtThresholdMAX, ! HistoricalMarketValueProvider historicalMarketValueProviderForInSample, ! HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, ! double inefficiencyLengthInMinutes, ! double minutesFromLastInefficiencyTimeToWaitBeforeOpening, ! double minutesFromLastLossOrProfitToWaitBeforeClosing, ! double maxOpeningLengthInMinutes, ! List<Time> openingTimesForAvailableBars, ! double stopLoss, double takeProfit) { this.pvoStrategyIntraday(eligiblesSelector, minimumNumberOfEligiblesForValidOptimization, ! inSampleDays , benchmark , numDaysBetweenEachOptimization , ! oversoldThreshold, overboughtThreshold, ! oversoldThresholdMAX, overboughtThresholdMAX, ! historicalMarketValueProviderForInSample, ! historicalMarketValueProviderForOutOfSample, ! inefficiencyLengthInMinutes, ! minutesFromLastInefficiencyTimeToWaitBeforeOpening, ! minutesFromLastLossOrProfitToWaitBeforeClosing, ! maxOpeningLengthInMinutes, ! openingTimesForAvailableBars, ! stopLoss, takeProfit); this.chosenPVOPositions = chosenPVOPositions; } public PVOStrategyIntraday(IEligiblesSelector eligiblesSelector, ! int minimumNumberOfEligiblesForValidOptimization, ! TestingPositions[] chosenPVOPositions, ! int inSampleDays, ! Benchmark benchmark, ! int numDaysBetweenEachOptimization, ! double oversoldThreshold, ! double overboughtThreshold, ! HistoricalMarketValueProvider historicalMarketValueProviderForInSample, ! HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, ! double inefficiencyLengthInMinutes, ! double minutesFromLastInefficiencyTimeToWaitBeforeOpening, ! double minutesFromLastLossOrProfitToWaitBeforeClosing, ! double maxOpeningLengthInMinutes, ! List<Time> openingTimesForAvailableBars, ! double stopLoss, double takeProfit) { this.pvoStrategyIntraday(eligiblesSelector, minimumNumberOfEligiblesForValidOptimization, ! inSampleDays , benchmark , numDaysBetweenEachOptimization , ! oversoldThreshold, overboughtThreshold, ! double.MaxValue, double.MaxValue, ! historicalMarketValueProviderForInSample, ! historicalMarketValueProviderForOutOfSample, ! inefficiencyLengthInMinutes, ! minutesFromLastInefficiencyTimeToWaitBeforeOpening, ! minutesFromLastLossOrProfitToWaitBeforeClosing, ! maxOpeningLengthInMinutes, ! openingTimesForAvailableBars, ! stopLoss, takeProfit); this.chosenPVOPositions = chosenPVOPositions; } private bool allTickersAreExchangedBeforeLastAvailableTime(DateTime fromDateTime, ! string[] tickers) { bool returnValue = true; --- 212,357 ---- public PVOStrategyIntraday(IEligiblesSelector eligiblesSelector, ! int minimumNumberOfEligiblesForValidOptimization, ! IInSampleChooser inSampleChooser, ! int inSampleDays, ! Benchmark benchmark, ! int numDaysBetweenEachOptimization, ! double oversoldThreshold, ! double overboughtThreshold, ! double oversoldThresholdMAX, ! double overboughtThresholdMAX, ! HistoricalMarketValueProvider historicalMarketValueProviderForInSample, ! HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, ! double inefficiencyLengthInMinutes, ! int numberOfPreviousEfficientPeriods, ! double minutesFromLastInefficiencyTimeToWaitBeforeOpening, ! double minutesFromLastLossOrProfitToWaitBeforeClosing, ! double maxOpeningLengthInMinutes, ! List<Time> openingTimesForAvailableBars, ! double stopLoss, double takeProfit) { this.pvoStrategyIntraday(eligiblesSelector, minimumNumberOfEligiblesForValidOptimization, ! inSampleDays , benchmark , numDaysBetweenEachOptimization , ! oversoldThreshold, overboughtThreshold, ! oversoldThresholdMAX, overboughtThresholdMAX, ! historicalMarketValueProviderForInSample, ! historicalMarketValueProviderForOutOfSample, ! inefficiencyLengthInMinutes, ! numberOfPreviousEfficientPeriods, ! minutesFromLastInefficiencyTimeToWaitBeforeOpening, ! minutesFromLastLossOrProfitToWaitBeforeClosing, ! maxOpeningLengthInMinutes, ! openingTimesForAvailableBars, ! stopLoss, takeProfit); this.inSampleChooser = inSampleChooser; } public PVOStrategyIntraday(IEligiblesSelector eligiblesSelector, ! int minimumNumberOfEligiblesForValidOptimization, ! IInSampleChooser inSampleChooser, ! int inSampleDays, ! Benchmark benchmark, ! int numDaysBetweenEachOptimization, ! double oversoldThreshold, ! double overboughtThreshold, ! HistoricalMarketValueProvider historicalMarketValueProviderForInSample, ! HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, ! double inefficiencyLengthInMinutes, ! int numberOfPreviousEfficientPeriods, ! double minutesFromLastInefficiencyTimeToWaitBeforeOpening, ! double minutesFromLastLossOrProfitToWaitBeforeClosing, ! double maxOpeningLengthInMinutes, ! List<Time> openingTimesForAvailableBars, ! double stopLoss, double takeProfit) { this.pvoStrategyIntraday(eligiblesSelector, minimumNumberOfEligiblesForValidOptimization, ! inSampleDays , benchmark , numDaysBetweenEachOptimization , ! oversoldThreshold, overboughtThreshold, ! double.MaxValue, double.MaxValue, ! historicalMarketValueProviderForInSample, ! historicalMarketValueProviderForOutOfSample, ! inefficiencyLengthInMinutes, ! numberOfPreviousEfficientPeriods, ! minutesFromLastInefficiencyTimeToWaitBeforeOpening, ! minutesFromLastLossOrProfitToWaitBeforeClosing, ! maxOpeningLengthInMinutes, ! openingTimesForAvailableBars, ! stopLoss, takeProfit); this.inSampleChooser = inSampleChooser; } public PVOStrategyIntraday(IEligiblesSelector eligiblesSelector, ! int minimumNumberOfEligiblesForValidOptimization, ! TestingPositions[] chosenPVOPositions, ! int inSampleDays, ! Benchmark benchmark, ! int numDaysBetweenEachOptimization, ! double oversoldThreshold, ! double overboughtThreshold, ! double oversoldThresholdMAX, ! double overboughtThresholdMAX, ! HistoricalMarketValueProvider historicalMarketValueProviderForInSample, ! HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, ! double inefficiencyLengthInMinutes, ! int numberOfPreviousEfficientPeriods, ! double minutesFromLastInefficiencyTimeToWaitBeforeOpening, ! double minutesFromLastLossOrProfitToWaitBeforeClosing, ! double maxOpeningLengthInMinutes, ! List<Time> openingTimesForAvailableBars, ! double stopLoss, double takeProfit) { this.pvoStrategyIntraday(eligiblesSelector, minimumNumberOfEligiblesForValidOptimization, ! inSampleDays , benchmark , numDaysBetweenEachOptimization , ! oversoldThreshold, overboughtThreshold, ! oversoldThresholdMAX, overboughtThresholdMAX, ! historicalMarketValueProviderForInSample, ! historicalMarketValueProviderForOutOfSample, ! inefficiencyLengthInMinutes, ! numberOfPreviousEfficientPeriods, ! minutesFromLastInefficiencyTimeToWaitBeforeOpening, ! minutesFromLastLossOrProfitToWaitBeforeClosing, ! maxOpeningLengthInMinutes, ! openingTimesForAvailableBars, ! stopLoss, takeProfit); this.chosenPVOPositions = chosenPVOPositions; } public PVOStrategyIntraday(IEligiblesSelector eligiblesSelector, ! int minimumNumberOfEligiblesForValidOptimization, ! TestingPositions[] chosenPVOPositions, ! int inSampleDays, ! Benchmark benchmark, ! int numDaysBetweenEachOptimization, ! double oversoldThreshold, ! double overboughtThreshold, ! HistoricalMarketValueProvider historicalMarketValueProviderForInSample, ! HistoricalMarketValueProvider historicalMarketValueProviderForOutOfSample, ! double inefficiencyLengthInMinutes, ! int numberOfPreviousEfficientPeriods, ! double minutesFromLastInefficiencyTimeToWaitBeforeOpening, ! double minutesFromLastLossOrProfitToWaitBeforeClosing, ! double maxOpeningLengthInMinutes, ! List<Time> openingTimesForAvailableBars, ! double stopLoss, double takeProfit) { this.pvoStrategyIntraday(eligiblesSelector, minimumNumberOfEligiblesForValidOptimization, ! inSampleDays , benchmark , numDaysBetweenEachOptimization , ! oversoldThreshold, overboughtThreshold, ! double.MaxValue, double.MaxValue, ! historicalMarketValueProviderForInSample, ! historicalMarketValueProviderForOutOfSample, ! inefficiencyLengthInMinutes, ! numberOfPreviousEfficientPeriods, ! minutesFromLastInefficiencyTimeToWaitBeforeOpening, ! minutesFromLastLossOrProfitToWaitBeforeClosing, ! maxOpeningLengthInMinutes, ! openingTimesForAvailableBars, ! stopLoss, takeProfit); this.chosenPVOPositions = chosenPVOPositions; } private bool allTickersAreExchangedBeforeLastAvailableTime(DateTime fromDateTime, ! string[] tickers) { bool returnValue = true; *************** *** 348,352 **** for( int i = 0; i < tickers.Length; i++ ) { ! Bars currentTickerBars = new Bars(tickers[i], fromDateTime, Time.GetDateTimeFromMerge(fromDateTime, --- 359,363 ---- for( int i = 0; i < tickers.Length; i++ ) { ! Bars currentTickerBars = new Bars(tickers[i], fromDateTime, Time.GetDateTimeFromMerge(fromDateTime, *************** *** 389,411 **** return returnValue; } ! #region newDateTimeEventHandler_closePositions ! private void newDateTimeEventHandler_closePositions(Time currentDailyTime) { bool positionsHaveBeenOpenedEnough = ! (this.account.Portfolio.Count > 0 && ! this.lastEntryTime.AddMinutes(maxOpeningLengthInMinutes) <= currentDailyTime); ! bool isTimeToProfitOrToStopALoss = ! this.account.Portfolio.Count > 0 && ! (this.takeProfitConditionReached || this.stopLossConditionReached) && ! (this.lastProfitOrLossTime.AddMinutes(this.minutesFromLastLossOrProfitToWaitBeforeClosing) == currentDailyTime); if( (positionsHaveBeenOpenedEnough || isTimeToProfitOrToStopALoss ) && ! allTickersAreExchanged( this.now(), AccountManager.GetTickersInOpenedPositions(this.account) ) ) { ! AccountManager.ClosePositions( this.account ); ! this.lastEntryTime = new Time("00:00:00"); ! this.lastInefficiencyTime = new Time("00:00:00"); } } --- 400,425 ---- return returnValue; } ! #region newDateTimeEventHandler_closePositions ! private void newDateTimeEventHandler_closePositions(Time currentDailyTime) { bool positionsHaveBeenOpenedEnough = ! (this.account.Portfolio.Count > 0 && ! this.lastEntryTime.AddMinutes(maxOpeningLengthInMinutes) <= currentDailyTime); ! bool isTimeToProfitOrToStopALoss = ! this.account.Portfolio.Count > 0 && ! (this.takeProfitConditionReached || this.stopLossConditionReached) && ! (this.lastProfitOrLossTime.AddMinutes(this.minutesFromLastLossOrProfitToWaitBeforeClosing) == currentDailyTime); if( (positionsHaveBeenOpenedEnough || isTimeToProfitOrToStopALoss ) && ! allTickersAreExchanged( this.now(), AccountManager.GetTickersInOpenedPositions(this.account) ) ) { ! AccountManager.ClosePositions( this.account ); ! this.lastEntryTime = new Time("00:00:00"); ! this.lastInefficiencyTime = new Time("00:00:00"); ! this.lastProfitOrLossTime = new Time("00:00:00"); ! this.takeProfitConditionReached = false; ! this.stopLossConditionReached = false; } } *************** *** 418,482 **** DateTime dateTimeForClose = Time.GetDateTimeFromMerge( this.now(), timeForClose ); if( this.account.Portfolio.Count == 0 && ! this.positionsForOutOfSample != null && ! timeForClose <= getLastEventTimeWithCachedBars() && ! this.allTickersAreExchanged( this.now(), this.positionsForOutOfSample.WeightedPositions.SignedTickers.Tickers ) && ! this.allTickersAreExchangedBeforeLastAvailableTime( dateTimeForClose, this.positionsForOutOfSample.WeightedPositions.SignedTickers.Tickers ) ) { switch (this.positionsForOutOfSampleStatus) { case PVOPositionsStatus.Overbought: - { - #region manage Overbought case - this.positionsForOutOfSample.WeightedPositions.Reverse(); - try - { - AccountManager.OpenPositions( this.positionsForOutOfSample.WeightedPositions, - this.account ); - this.lastEntryTime = currentDailyTime; - this.previousAccountValue = this.account.GetMarketValue(); - } - catch(Exception ex) - { - string forBreakpoint = ex.Message; forBreakpoint = forBreakpoint + ""; - } - finally { this.positionsForOutOfSample.WeightedPositions.Reverse(); } - #endregion - break; - } case PVOPositionsStatus.Oversold: - { - #region manage Oversold case - try { ! AccountManager.OpenPositions( this.positionsForOutOfSample.WeightedPositions, ! this.account ); ! this.lastEntryTime = currentDailyTime; ! this.previousAccountValue = this.account.GetMarketValue(); ! } ! catch(Exception ex) ! { ! string forBreakpoint = ex.Message; forBreakpoint = forBreakpoint + ""; } - #endregion oversold case - break; - } case PVOPositionsStatus.InTheMiddle://that is ! { //pvoPositionsForOutOfSample has not been set ! ! break; ! } default: ! { ! //it should never been reached ! break; ! } } } } #endregion newDateTimeEventHandler_openPositions #region newDateTimeEventHandler_inefficiencyIsMovingBack private bool newDateTimeEventHandler_inefficiencyIsMovingBack(Time currentDailyTime) --- 432,538 ---- DateTime dateTimeForClose = Time.GetDateTimeFromMerge( this.now(), timeForClose ); if( this.account.Portfolio.Count == 0 && ! this.positionsForOutOfSample != null && ! timeForClose <= getLastEventTimeWithCachedBars() && ! this.allTickersAreExchanged( this.now(), this.positionsForOutOfSample.WeightedPositions.SignedTickers.Tickers ) && ! this.allTickersAreExchangedBeforeLastAvailableTime( dateTimeForClose, this.positionsForOutOfSample.WeightedPositions.SignedTickers.Tickers ) ) { switch (this.positionsForOutOfSampleStatus) { case PVOPositionsStatus.Overbought: { + #region manage Overbought case this.positionsForOutOfSample.WeightedPositions.Reverse(); + try + { + AccountManager.OpenPositions( this.positionsForOutOfSample.WeightedPositions, + this.account ); + this.lastEntryTime = currentDailyTime; + this.previousAccountValue = this.account.GetMarketValue(); + } + catch(Exception ex) + { + string forBreakpoint = ex.Message; forBreakpoint = forBreakpoint + ""; + } + finally + { + this.positionsForOutOfSample.WeightedPositions.Reverse(); + } + #endregion + break; } case PVOPositionsStatus.Oversold: { ! #region manage Oversold case ! try ! { ! AccountManager.OpenPositions( this.positionsForOutOfSample.WeightedPositions, ! this.account ); ! this.lastEntryTime = currentDailyTime; ! this.previousAccountValue = this.account.GetMarketValue(); ! } ! catch(Exception ex) ! { ! string forBreakpoint = ex.Message; forBreakpoint = forBreakpoint + ""; ! } ! #endregion oversold case ! break; } case PVOPositionsStatus.InTheMiddle://that is ! { //pvoPositionsForOutOfSample has not been set ! ! break; ! } default: ! { ! //it should never been reached ! break; ! } } } } #endregion newDateTimeEventHandler_openPositions + + #region newDateTimeEventHandler_previousPeriodsWereEfficient + private PVOPositionsStatus newDateTimeEventHandler_previousPeriodsWereEfficient_getStatus( DateTime beginOfOscillatingPeriod, + DateTime endOfOscillatingPeriod ) + { + PVOPositionsStatus returnValue = PVOPositionsStatus.NotComputable; + if(this.positionsForOutOfSample != null) + try{ + returnValue = + this.positionsForOutOfSample.GetStatus( beginOfOscillatingPeriod, endOfOscillatingPeriod, + this.benchmark.Ticker, this.historicalMarketValueProviderForOutOfSample, + this.oversoldThreshold, + this.oversoldThresholdMAX, + this.overboughtThreshold, + this.overboughtThresholdMAX ); + }catch{} + return returnValue; + } + + private bool newDateTimeEventHandler_previousPeriodsWereEfficient(Time currentDailyTime) + { + bool returnValue = true; + PVOPositionsStatus statusForCurrentPeriodBeforeInefficiencyTime; + for( int i = 1; i <= this.numberOfPreviousEfficientPeriods; i++ ) + { + DateTime beginOfOscillatingPeriod = + Time.GetDateTimeFromMerge( this.now() , this.lastInefficiencyTime.AddMinutes( - (i+1)*this.inefficiencyLengthInMinutes ) ); + DateTime endOfOscillatingPeriod = + Time.GetDateTimeFromMerge( this.now() , this.lastInefficiencyTime.AddMinutes( - i*this.inefficiencyLengthInMinutes ) ); + statusForCurrentPeriodBeforeInefficiencyTime = + this.newDateTimeEventHandler_previousPeriodsWereEfficient_getStatus( beginOfOscillatingPeriod, + endOfOscillatingPeriod ); + if( statusForCurrentPeriodBeforeInefficiencyTime != PVOPositionsStatus.InTheMiddle ) + { + returnValue = false; + i = this.numberOfPreviousEfficientPeriods; + } + } + return returnValue; + } + #endregion newDateTimeEventHandler_previousPeriodsWereEfficient + #region newDateTimeEventHandler_inefficiencyIsMovingBack private bool newDateTimeEventHandler_inefficiencyIsMovingBack(Time currentDailyTime) *************** *** 485,530 **** DateTime beginOfOscillatingPeriod = Time.GetDateTimeFromMerge( this.now() , this.lastInefficiencyTime ); ! DateTime endOfOscillatingPeriod = Time.GetDateTimeFromMerge( this.now() , currentDailyTime ); PVOPositionsStatus currentStatusForCurrentPositions = PVOPositionsStatus.InTheMiddle; ! double coefficientForThresholdLevelComputationForMovingBackSignal = //(this.overboughtThreshold - this.takeProfit)/this.overboughtThreshold; this.minutesFromLastInefficiencyTimeToWaitBeforeOpening/ // this.inefficiencyLengthInMinutes; ! 100000; if(this.positionsForOutOfSample != null) try{ ! currentStatusForCurrentPositions = ! this.positionsForOutOfSample.GetStatus( beginOfOscillatingPeriod, endOfOscillatingPeriod, ! this.benchmark.Ticker, this.historicalMarketValueProviderForOutOfSample, ! this.oversoldThreshold * coefficientForThresholdLevelComputationForMovingBackSignal, ! this.oversoldThreshold, ! this.overboughtThreshold * coefficientForThresholdLevelComputationForMovingBackSignal, ! this.overboughtThreshold ); ! }catch{} returnValue = ( (currentStatusForCurrentPositions == PVOPositionsStatus.Overbought && ! this.positionsForOutOfSampleStatus == PVOPositionsStatus.Oversold) || ! (currentStatusForCurrentPositions == PVOPositionsStatus.Oversold && ! this.positionsForOutOfSampleStatus == PVOPositionsStatus.Overbought) ); ! if( (returnValue == false && ! currentDailyTime >= this.lastInefficiencyTime.AddMinutes(this.inefficiencyLengthInMinutes) ) || ! returnValue == true ) ! //positions are not moving back and the same n° of minutes as inefficiency length ! //has elapsed OR positions are moving back (the gap is closing) ! this.lastInefficiencyTime = new Time(0,0,0); //it forces a new research of an inefficiency return returnValue; } - - #endregion newDateTimeEventHandler_inefficiencyIsMovingBack ! #region newDateTimeEventHandler_updateStatus private void newDateTimeEventHandler_setPositionsAndStatus(Time currentDailyTime) { ! DateTime beginOfOscillatingPeriod = Time.GetDateTimeFromMerge(this.now() , currentDailyTime.AddMinutes(-inefficiencyLengthInMinutes) ); ! DateTime endOfOscillatingPeriod = Time.GetDateTimeFromMerge(this.now() , currentDailyTime); // this.positionsForOutOfSample = null; --- 541,578 ---- DateTime beginOfOscillatingPeriod = Time.GetDateTimeFromMerge( this.now() , this.lastInefficiencyTime ); ! DateTime endOfOscillatingPeriod = Time.GetDateTimeFromMerge( this.now() , currentDailyTime ); PVOPositionsStatus currentStatusForCurrentPositions = PVOPositionsStatus.InTheMiddle; ! double coefficientForThresholdLevelComputationForMovingBackSignal = //(this.overboughtThreshold - this.takeProfit)/this.overboughtThreshold; this.minutesFromLastInefficiencyTimeToWaitBeforeOpening/ // this.inefficiencyLengthInMinutes; ! 100000; if(this.positionsForOutOfSample != null) try{ ! currentStatusForCurrentPositions = ! this.positionsForOutOfSample.GetStatus( beginOfOscillatingPeriod, endOfOscillatingPeriod, ! this.benchmark.Ticker, this.historicalMarketValueProviderForOutOfSample, ! this.oversoldThreshold * coefficientForThresholdLevelComputationForMovingBackSignal, ! this.oversoldThreshold, ! this.overboughtThreshold * coefficientForThresholdLevelComputationForMovingBackSignal, ! this.overboughtThreshold ); ! }catch{} returnValue = ( (currentStatusForCurrentPositions == PVOPositionsStatus.Overbought && ! this.positionsForOutOfSampleStatus == PVOPositionsStatus.Oversold) || ! (currentStatusForCurrentPositions == PVOPositionsStatus.Oversold && ! this.positionsForOutOfSampleStatus == PVOPositionsStatus.Overbought) ); return returnValue; } #endregion newDateTimeEventHandler_inefficiencyIsMovingBack ! #region newDateTimeEventHandler_updateStatus private void newDateTimeEventHandler_setPositionsAndStatus(Time currentDailyTime) { ! DateTime beginOfOscillatingPeriod = Time.GetDateTimeFromMerge(this.now() , currentDailyTime.AddMinutes(-inefficiencyLengthInMinutes) ); ! DateTime endOfOscillatingPeriod = Time.GetDateTimeFromMerge(this.now() , currentDailyTime); // this.positionsForOutOfSample = null; *************** *** 536,546 **** if(this.chosenPVOPositions[i] != null) try{ ! this.positionsForOutOfSampleStatus = ! ((PVOPositions)this.chosenPVOPositions[i]).GetStatus(beginOfOscillatingPeriod, endOfOscillatingPeriod, this.benchmark.Ticker, this.historicalMarketValueProviderForOutOfSample, this.oversoldThresholdMAX, this.overboughtThresholdMAX); - - }catch(Exception ex){string str = ex.ToString();} if(this.positionsForOutOfSampleStatus == PVOPositionsStatus.Oversold || this.positionsForOutOfSampleStatus == PVOPositionsStatus.Overbought ) --- 584,594 ---- if(this.chosenPVOPositions[i] != null) try{ ! this.positionsForOutOfSampleStatus = ! ((PVOPositions)this.chosenPVOPositions[i]).GetStatus(beginOfOscillatingPeriod, endOfOscillatingPeriod, this.benchmark.Ticker, this.historicalMarketValueProviderForOutOfSample, this.oversoldThresholdMAX, this.overboughtThresholdMAX); + }catch(Exception ex){string str = ex.ToString();} + if(this.positionsForOutOfSampleStatus == PVOPositionsStatus.Oversold || this.positionsForOutOfSampleStatus == PVOPositionsStatus.Overbought ) *************** *** 558,565 **** { //this.previousAccountValue has been set at opening positions ! this.stopLossConditionReached = false; ! this.takeProfitConditionReached = false; ! this.lastProfitOrLossTime = new Time("00:00:00"); ! if(this.account.Portfolio.Count > 0) { try{ --- 606,613 ---- { //this.previousAccountValue has been set at opening positions ! if( this.account.Portfolio.Count > 0 && ! this.takeProfitConditionReached == false && ! this.stopLossConditionReached == false && ! this.lastProfitOrLossTime == new Time("00:00:00") ) { try{ *************** *** 583,587 **** } catch(Exception ex) ! {string forBreakpoint = ex.Message; forBreakpoint = forBreakpoint + "";} } } --- 631,635 ---- } catch(Exception ex) ! {string forBreakpoint = ex.Message; forBreakpoint = forBreakpoint + "";} } } *************** *** 589,592 **** --- 637,650 ---- #endregion newDateTimeEventHandler_updateStopLossAndTakeProfitConditions + private void newDateTimeEventHandler_resetForNewResearch(bool inefficiencyIsMovingBack, + bool previousPeriodsWereEfficient, + Time currentTime) + { + if( currentTime > this.lastInefficiencyTime.AddMinutes(this.minutesFromLastInefficiencyTimeToWaitBeforeOpening) || + (inefficiencyIsMovingBack == true && previousPeriodsWereEfficient == true) ) + + this.lastInefficiencyTime = new Time(0,0,0); //it forces a new research of an inefficiency + } + public virtual void NewDateTimeEventHandler( Object sender , DateTime dateTime ) *************** *** 596,618 **** this.newDateTimeEventHandler_closePositions(currentTime); if( this.account.Portfolio.Count == 0 && ! this.chosenPVOPositions != null && ! this.lastInefficiencyTime == new Time(0,0,0) && ! currentTime < getLastEventTimeWithCachedBars() && ! currentTime >= ! getFirstEventTimeWithCachedBars().AddMinutes(inefficiencyLengthInMinutes) ) ! //portfolio empty, optimization done, no inefficiency found, time OK this.newDateTimeEventHandler_setPositionsAndStatus(currentTime); if( this.account.Portfolio.Count == 0 && ! currentTime >= ! this.lastInefficiencyTime.AddMinutes(this.minutesFromLastInefficiencyTimeToWaitBeforeOpening) ! && ! this.newDateTimeEventHandler_inefficiencyIsMovingBack(currentTime) ! ) ! //it's time for starting checking if the last inefficiency found is moving back this.newDateTimeEventHandler_openPositions(currentTime); ! if( currentTime == getLastEventTimeWithCachedBars() ) ! //it's time for new optimization, if the case { this.newDateTimeEventHandler_updateTestingPositions( dateTime ); --- 654,682 ---- this.newDateTimeEventHandler_closePositions(currentTime); if( this.account.Portfolio.Count == 0 && ! this.chosenPVOPositions != null && ! this.lastInefficiencyTime == new Time(0,0,0) && ! currentTime < getLastEventTimeWithCachedBars() && ! currentTime >= ! getFirstEventTimeWithCachedBars().AddMinutes( inefficiencyLengthInMinutes + ! inefficiencyLengthInMinutes * this.numberOfPreviousEfficientPeriods ) ) ! //portfolio empty, optimization done, no inefficiency found (or found but not deployed), time OK this.newDateTimeEventHandler_setPositionsAndStatus(currentTime); + bool inefficiencyIsMovingBack = + this.newDateTimeEventHandler_inefficiencyIsMovingBack(currentTime); + bool previousPeriodsWereEfficient = + this.newDateTimeEventHandler_previousPeriodsWereEfficient(currentTime); if( this.account.Portfolio.Count == 0 && ! this.lastInefficiencyTime != new Time(0, 0, 0) && ! currentTime >= ! this.lastInefficiencyTime.AddMinutes(this.minutesFromLastInefficiencyTimeToWaitBeforeOpening) ! && inefficiencyIsMovingBack && previousPeriodsWereEfficient ! ) this.newDateTimeEventHandler_openPositions(currentTime); ! this.newDateTimeEventHandler_resetForNewResearch(inefficiencyIsMovingBack, ! previousPeriodsWereEfficient, ! currentTime); if( currentTime == getLastEventTimeWithCachedBars() ) ! //it's time for new optimization, if the case { this.newDateTimeEventHandler_updateTestingPositions( dateTime ); *************** *** 621,625 **** this.lastInefficiencyTime = new Time(0,0,0); } - } --- 685,688 ---- *************** *** 688,695 **** this.benchmark.Ticker ); if(this.inSampleChooser is PVOIntradayCorrelationChooser) ! returnIntervals = ! new IntradayIntervals(firstDateTime, lastDateTime, ! ((PVOIntradayCorrelationChooser)this.inSampleChooser).ReturnIntervalLengthInMinutes, ! this.benchmark.Ticker); if( this.inSampleChooser is PVOCorrelationChooser ) --- 751,758 ---- this.benchmark.Ticker ); if(this.inSampleChooser is PVOIntradayCorrelationChooser) ! returnIntervals = ! new IntradayIntervals(firstDateTime, lastDateTime, ! ((PVOIntradayCorrelationChooser)this.inSampleChooser).ReturnIntervalLengthInMinutes, ! this.benchmark.Ticker); if( this.inSampleChooser is PVOCorrelationChooser ) Index: PVOStrategyIntradayMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVOStrategyIntradayMain.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PVOStrategyIntradayMain.cs 29 Mar 2009 18:04:32 -0000 1.5 --- PVOStrategyIntradayMain.cs 29 Mar 2009 18:31:00 -0000 1.6 *************** *** 66,69 **** --- 66,70 ---- private HistoricalMarketValueProvider historicalMarketValueProviderForTheBackTester; private double inefficiencyLengthInMinutes; + private int numberOfPreviousEfficientPeriods; private double maxOpeningLengthInMinutes; private double minutesFromLastInefficiencyToWaitBeforeOpening; *************** *** 78,82 **** { this.inefficiencyLengthInMinutes = 30; ! this.maxOpeningLengthInMinutes = 240; this.minutesFromLastInefficiencyToWaitBeforeOpening = 1; this.minutesFromLastLossOrProfitToWaitBeforeClosing = 0; --- 79,84 ---- { this.inefficiencyLengthInMinutes = 30; ! this.numberOfPreviousEfficientPeriods = 1; ! this.maxOpeningLengthInMinutes = 180; this.minutesFromLastInefficiencyToWaitBeforeOpening = 1; this.minutesFromLastLossOrProfitToWaitBeforeClosing = 0; *************** *** 84,88 **** this.intervalFrameInSeconds = 60; ! this.firstDateTime = new DateTime( 2006 , 2 , 1 ); this.lastDateTime = new DateTime( 2006 , 12, 31 ); --- 86,90 ---- this.intervalFrameInSeconds = 60; ! this.firstDateTime = new DateTime( 2006 , 1, 1 ); this.lastDateTime = new DateTime( 2006 , 12, 31 ); *************** *** 93,98 **** this.historicalMarketValueProviderForInSample = ! // new HistoricalAdjustedQuoteProvider(); ! new HistoricalBarInterpolatingProvider( this.getBarCache() ); this.historicalMarketValueProviderForTheBackTester = --- 95,100 ---- this.historicalMarketValueProviderForInSample = ! new HistoricalAdjustedQuoteProvider(); ! // new HistoricalBarInterpolatingProvider( this.getBarCache() ); this.historicalMarketValueProviderForTheBackTester = *************** *** 117,131 **** int maxNumberOfEligiblesToBeChosen = 100; ! string tickersGroupId = "SP500"; bool temporizedGroup = true; int numDaysForAverageRawOpenPriceComputation = 10; ! double minPrice = 30; double maxPrice = 300; ! // int maxNumberOfMostLiquidTickersToBeChosen = 150; ! // int numDaysForVolatility = 10; ! int minimumNumberOfMinutelyBarsForEachDayForInSample = 20; // IEligiblesSelector eligiblesSelector = --- 119,134 ---- int maxNumberOfEligiblesToBeChosen = 100; ! //int numOfTopRowsToDeleteFromSelectorByLiquidity = 0; ! string tickersGroupId = "SP500"; bool temporizedGroup = true; int numDaysForAverageRawOpenPriceComputation = 10; ! double minPrice = 25; double maxPrice = 300; ! int maxNumberOfMostLiquidTickersToBeChosen = 150; ! int numDaysForVolatility = 10; ! // int minimumNumberOfMinutelyBarsForEachDayForInSample = 20; // IEligiblesSelector eligiblesSelector = *************** *** 137,156 **** // this.benchmark.Ticker ); // LAST GOOD - // IEligiblesSelector eligiblesSelector = - // new ByPriceMostLiquidLessVolatileOTCAlwaysQuoted( - // tickersGroupId , temporizedGroup , - // maxNumberOfEligiblesToBeChosen , - // maxNumberOfMostLiquidTickersToBeChosen , - // numDaysForAverageRawOpenPriceComputation , - // numDaysForVolatility , - // minPrice , maxPrice ); - IEligiblesSelector eligiblesSelector = ! new ByPriceMostLiquidAlwaysIntradayQuoted( ! tickersGroupId , this.benchmark, temporizedGroup , maxNumberOfEligiblesToBeChosen , ! numDaysForAverageRawOpenPriceComputation , ! minPrice , maxPrice, ! minimumNumberOfMinutelyBarsForEachDayForInSample ); // IEligiblesSelector eligiblesSelector = --- 140,160 ---- // this.benchmark.Ticker ); // LAST GOOD IEligiblesSelector eligiblesSelector = ! new ByPriceMostLiquidLessVolatileOTCAlwaysQuoted( ! tickersGroupId , temporizedGroup , maxNumberOfEligiblesToBeChosen , ! maxNumberOfMostLiquidTickersToBeChosen , ! numDaysForAverageRawOpenPriceComputation , ! numDaysForVolatility , ! minPrice , maxPrice ); ! ! // IEligiblesSelector eligiblesSelector = ! // new ByPriceMostLiquidAlwaysIntradayQuoted( ! // tickersGroupId , this.benchmark, temporizedGroup , ! // maxNumberOfEligiblesToBeChosen , ! // numOfTopRowsToDeleteFromSelectorByLiquidity, ! // numDaysForAverageRawOpenPriceComputation , ! // minPrice , maxPrice, ! // minimumNumberOfMinutelyBarsForEachDayForInSample ); // IEligiblesSelector eligiblesSelector = *************** *** 187,196 **** double maxCorrelationAllowed = 0.96; ! int numberOfBestTestingPositionsToBeReturned = 50; ! numberOfBestTestingPositionsToBeReturned = 50; bool balancedWeightsOnVolatilityBase = true; float minimumAbsoluteReturnValue = 0.00005f; float maximumAbsoluteReturnValue = 100000f; ! int returnIntervalLengthInMinutesForCorrelationProvider = 120; //correlation is computed only for returns //between minimum and maximum --- 191,199 ---- double maxCorrelationAllowed = 0.96; ! int numberOfBestTestingPositionsToBeReturned = 40; bool balancedWeightsOnVolatilityBase = true; float minimumAbsoluteReturnValue = 0.00005f; float maximumAbsoluteReturnValue = 100000f; ! //int returnIntervalLengthInMinutesForCorrelationProvider = 120; //correlation is computed only for returns //between minimum and maximum *************** *** 204,214 **** // minimumAbsoluteReturnValue , maximumAbsoluteReturnValue, this.benchmark.Ticker); IInSampleChooser inSampleChooser = ! // new PVO_CTCCorrelationChooser(numberOfBestTestingPositionsToBeReturned, ! // 1 , maxCorrelationAllowed , balancedWeightsOnVolatilityBase, ! // minimumAbsoluteReturnValue , maximumAbsoluteReturnValue, this.benchmark.Ticker); ! new PVOIntradayCorrelationChooser(numberOfBestTestingPositionsToBeReturned, ! returnIntervalLengthInMinutesForCorrelationProvider , ! maxCorrelationAllowed , balancedWeightsOnVolatilityBase, minimumAbsoluteReturnValue , maximumAbsoluteReturnValue, this.benchmark.Ticker); // //office --- 207,217 ---- // minimumAbsoluteReturnValue , maximumAbsoluteReturnValue, this.benchmark.Ticker); IInSampleChooser inSampleChooser = ! new PVO_CTCCorrelationChooser(numberOfBestTestingPositionsToBeReturned, ! 1 , maxCorrelationAllowed , balancedWeightsOnVolatilityBase, minimumAbsoluteReturnValue , maximumAbsoluteReturnValue, this.benchmark.Ticker); + // new PVOIntradayCorrelationChooser(numberOfBestTestingPositionsToBeReturned, + // returnIntervalLengthInMinutesForCorrelationProvider , + // maxCorrelationAllowed , balancedWeightsOnVolatilityBase, + // minimumAbsoluteReturnValue , maximumAbsoluteReturnValue, this.benchmark.Ticker); // //office *************** *** 220,224 **** // inSampleChooser = // new PVOChooserFromSavedBackTestLog( ! // @"C:\Utente\MarcoVarie\Vari\qP\LogArchive\2009_02_17_23_17_03_PVOIntraday_from_2006_01_01_to_2007_12_31_annlRtrn_24.44_maxDD_3.05\2009_02_17_23_17_03_PVOIntraday_from_2006_01_01_to_2007_12_31_annlRtrn_24.44_maxDD_3.05.qpL", // numberOfBestTestingPositionsToBeReturned); return inSampleChooser; --- 223,227 ---- // inSampleChooser = // new PVOChooserFromSavedBackTestLog( ! // @"C:\Utente\MarcoVarie\Vari\qP\LogArchive\2009_03_22_10_29_04_PVOIntraday_from_2006_02_01_to_2006_12_29_annlRtrn_.17_maxDD_5.03\2009_03_22_10_29_04_PVOIntraday_from_2006_02_01_to_2006_12_29_annlRtrn_.17_maxDD_5.03.qpL", // numberOfBestTestingPositionsToBeReturned); return inSampleChooser; *************** *** 228,240 **** { //int inSampleDays = 90; ! int inSampleDays = 30; ! int numDaysBetweenEachOptimization = 4; int minNumOfEligiblesForValidOptimization = 20; ! double oversoldThreshold = 0.005;//0.006 ! double overboughtThreshold = 0.005;//0.006 ! double oversoldThresholdMAX = 0.025; ! double overboughtThresholdMAX = 0.025; double stopLoss = 0.02; ! double takeProfit = 0.0025;//0.0045 IStrategyForBacktester strategyForBacktester --- 231,243 ---- { //int inSampleDays = 90; ! int inSampleDays = 90; ! int numDaysBetweenEachOptimization = 5; int minNumOfEligiblesForValidOptimization = 20; ! double oversoldThreshold = 0.006;//0.006 ! double overboughtThreshold = 0.006;//0.006 ! double oversoldThresholdMAX = 0.02; ! double overboughtThresholdMAX = 0.02; double stopLoss = 0.02; ! double takeProfit = 0.003;//0.0045 IStrategyForBacktester strategyForBacktester *************** *** 250,255 **** historicalMarketValueProviderForInSample, historicalMarketValueProviderForOutOfSample, ! inefficiencyLengthInMinutes , minutesFromLastInefficiencyToWaitBeforeOpening, ! this.minutesFromLastLossOrProfitToWaitBeforeClosing, maxOpeningLengthInMinutes, this.getDailyTimes(), stopLoss , takeProfit ); --- 253,260 ---- historicalMarketValueProviderForInSample, historicalMarketValueProviderForOutOfSample, ! inefficiencyLengthInMinutes , ! numberOfPreviousEfficientPeriods, ! minutesFromLastInefficiencyToWaitBeforeOpening, ! minutesFromLastLossOrProfitToWaitBeforeClosing, maxOpeningLengthInMinutes, this.getDailyTimes(), stopLoss , takeProfit ); *************** *** 291,295 **** // new InteractiveBrokerAccountProvider(fixedPercentageSlippage); double cashToStart = 25000; ! double maxRunningHours = 15; EndOfDayStrategyBackTester endOfDayStrategyBackTester = new EndOfDayStrategyBackTester( --- 296,300 ---- // new InteractiveBrokerAccountProvider(fixedPercentageSlippage); double cashToStart = 25000; ! double maxRunningHours = 240; EndOfDayStrategyBackTester endOfDayStrategyBackTester = new EndOfDayStrategyBackTester( Index: PVOPositionsStatus.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVOPositionsStatus.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PVOPositionsStatus.cs 14 Aug 2008 23:28:06 -0000 1.2 --- PVOPositionsStatus.cs 29 Mar 2009 18:31:00 -0000 1.3 *************** *** 35,39 **** InTheMiddle, Overbought, ! OverMaximumThresholds } } --- 35,40 ---- InTheMiddle, Overbought, ! OverMaximumThresholds, ! NotComputable } } |
|
From: Marco M. <mi...@us...> - 2009-03-29 18:15:56
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv1812/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables Modified Files: RoundTrades.cs Log Message: The table RoundTrades in report has been fixed. Old reports are still deserializable. Index: RoundTrades.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables/RoundTrades.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RoundTrades.cs 15 Feb 2005 19:09:05 -0000 1.2 --- RoundTrades.cs 29 Mar 2009 18:15:50 -0000 1.3 *************** *** 12,20 **** { private ReportTable transactionTable; ! public RoundTrades( string reportName , ReportTable transactionTable ) : base( reportName + " - Round Trades" ) { this.transactionTable = transactionTable; this.DataTable = this.getRoundTrades(); } --- 12,33 ---- { private ReportTable transactionTable; ! private string fieldNameForTicker; ! private string fieldNameForDateTime; ! private string fieldNameForTransactionType; ! ! private void setFieldNames() ! { ! this.fieldNameForTicker = ! QuantProject.Business.Financial.Accounting.Reporting.Tables.Transactions.FieldNameForTicker; ! this.fieldNameForDateTime = ! QuantProject.Business.Financial.Accounting.Reporting.Tables.Transactions.FieldNameForDateTime; ! this.fieldNameForTransactionType = ! QuantProject.Business.Financial.Accounting.Reporting.Tables.Transactions.FieldNameForTransactionType; ! } public RoundTrades( string reportName , ReportTable transactionTable ) : base( reportName + " - Round Trades" ) { this.transactionTable = transactionTable; + this.setFieldNames(); this.DataTable = this.getRoundTrades(); } *************** *** 22,26 **** --- 35,41 ---- private void getRoundTradeTable_setColumns( DataTable roundTradeDataTable ) { + roundTradeDataTable.Columns.Add( fieldNameForTicker , Type.GetType( "System.String" ) ); roundTradeDataTable.Columns.Add( "Trade" , Type.GetType( "System.String" ) ); + roundTradeDataTable.Columns.Add( "Quantity" , Type.GetType( "System.Int32" ) ); roundTradeDataTable.Columns.Add( "EntryDate" , Type.GetType( "System.DateTime" ) ); roundTradeDataTable.Columns.Add( "EntryPrice" , Type.GetType( "System.Double" ) ); *************** *** 30,88 **** roundTradeDataTable.Columns.Add( "Profit" , Type.GetType( "System.Double" ) ); roundTradeDataTable.Columns.Add( "%Profit" , Type.GetType( "System.Double" ) ); ! roundTradeDataTable.Columns.Add( "#bars" , Type.GetType( "System.Int32" ) ); ! roundTradeDataTable.Columns.Add( "ProfitPerBar" , Type.GetType( "System.Double" ) ); //roundTradeDataTable.Columns.Add( "AccountValue" , Type.GetType( "System.Double" ) ); //roundTradeDataTable.Columns.Add( "PnL" , Type.GetType( "System.Double" ) ); } ! private void getRoundTradeTable_setRow( DataRow dataRow , DataTable roundTradeDataTable ) { ! DataRow roundTrade; ! switch ( (string)dataRow[ "TransactionType" ] ) ! { ! case "BuyLong": ! roundTrade = roundTradeDataTable.NewRow(); ! roundTrade[ "Trade" ] = "Long"; ! roundTrade[ "EntryDate" ] = dataRow[ "DateTime" ]; ! roundTrade[ "EntryPrice" ] = dataRow[ "Price" ]; ! roundTradeDataTable.Rows.Add( roundTrade ); ! break; ! case "Sell": ! roundTrade = roundTradeDataTable.Rows[ roundTradeDataTable.Rows.Count - 1 ]; ! roundTrade[ "ExitDate" ] = dataRow[ "DateTime" ]; ! roundTrade[ "ExitPrice" ] = dataRow[ "Price" ]; ! roundTrade[ "%chg" ] = ! ((double)roundTrade[ "ExitPrice" ] - (double)roundTrade[ "EntryPrice" ])/ ! ((double)roundTrade[ "EntryPrice" ])*100; ! roundTrade[ "%Profit" ] = roundTrade[ "%chg" ]; ! roundTrade[ "#bars" ] = ! ((TimeSpan)((DateTime)roundTrade[ "ExitDate" ] - (DateTime)roundTrade[ "EntryDate" ])).Days; ! roundTrade[ "ProfitPerBar" ] = (double)roundTrade[ "%chg" ] / (int)roundTrade[ "#bars" ]; ! break; ! case "SellShort": ! roundTrade = roundTradeDataTable.NewRow(); ! roundTrade[ "Trade" ] = "Short"; ! roundTrade[ "EntryDate" ] = dataRow[ "DateTime" ]; ! roundTrade[ "EntryPrice" ] = dataRow[ "Price" ]; ! roundTradeDataTable.Rows.Add( roundTrade ); ! break; ! case "Cover": ! roundTrade = roundTradeDataTable.Rows[ roundTradeDataTable.Rows.Count - 1 ]; ! roundTrade[ "ExitDate" ] = dataRow[ "DateTime" ]; ! roundTrade[ "ExitPrice" ] = dataRow[ "Price" ]; ! roundTrade[ "%chg" ] = ! ((double)roundTrade[ "ExitPrice" ] - (double)roundTrade[ "EntryPrice" ])/ ! ((double)roundTrade[ "EntryPrice" ])*100; ! roundTrade[ "%Profit" ] = - ((double)roundTrade[ "%chg" ]); ! roundTrade[ "#bars" ] = ! ((TimeSpan)((DateTime)roundTrade[ "ExitDate" ] - (DateTime)roundTrade[ "EntryDate" ])).Days; ! roundTrade[ "ProfitPerBar" ] = (double)roundTrade[ "%chg" ] / (int)roundTrade[ "#bars" ]; ! break; ! } ! } private void getRoundTradeTable_setRows( DataTable roundTradeDataTable ) { ! foreach (DataRow dataRow in this.transactionTable.DataTable.Rows ) ! getRoundTradeTable_setRow( dataRow , roundTradeDataTable ); } private DataTable getRoundTrades() --- 45,114 ---- roundTradeDataTable.Columns.Add( "Profit" , Type.GetType( "System.Double" ) ); roundTradeDataTable.Columns.Add( "%Profit" , Type.GetType( "System.Double" ) ); ! roundTradeDataTable.Columns.Add( "#minutes" , Type.GetType( "System.Int32" ) ); ! roundTradeDataTable.Columns.Add( "ProfitPerMinute" , Type.GetType( "System.Double" ) ); //roundTradeDataTable.Columns.Add( "AccountValue" , Type.GetType( "System.Double" ) ); //roundTradeDataTable.Columns.Add( "PnL" , Type.GetType( "System.Double" ) ); } ! private void getRoundTradeTable_addRow( int rowIndex, DataRow dataRow , DataTable roundTradeDataTable ) { ! DateTime startDateTimeOfTrade = (DateTime)dataRow[fieldNameForDateTime]; ! DateTime endDateTimeOfTrade = new DateTime(1900,1,1); ! string currentTicker = (string)dataRow[fieldNameForTicker]; ! string currentTradeType = (string)dataRow[fieldNameForTransactionType]; ! double signForRoundTradeProfit = 1.0; ! if(currentTradeType == "SellShort") ! signForRoundTradeProfit = -1.0; ! double entryPrice = (double)dataRow["Price"]; ! double exitPrice = 0.0; ! int instrumentQuantity = (int)dataRow["Quantity"]; ! for (int j = rowIndex + 1; j < this.transactionTable.DataTable.Rows.Count ; j++) ! { ! if( currentTicker == (string)this.transactionTable.DataTable.Rows[ j ][fieldNameForTicker] && ! ((currentTradeType == "BuyLong" && ! (string)this.transactionTable.DataTable.Rows[ j ][fieldNameForTransactionType] == "Sell") ! || ! (currentTradeType == "SellShort" && ! (string)this.transactionTable.DataTable.Rows[ j ][fieldNameForTransactionType] == "Cover") ! ) ) ! { ! endDateTimeOfTrade = ! (DateTime)this.transactionTable.DataTable.Rows[ j ][fieldNameForDateTime]; ! exitPrice = (double)this.transactionTable.DataTable.Rows[ j ]["Price"]; ! j = this.transactionTable.DataTable.Rows.Count; ! } ! } ! TimeSpan timeSpanBetweenEnterAndExit = ! endDateTimeOfTrade.Subtract(startDateTimeOfTrade); ! DataRow roundTrade = roundTradeDataTable.NewRow(); ! roundTrade[ fieldNameForTicker ] = currentTicker; ! roundTrade[ "Trade" ] = currentTradeType; ! roundTrade[ "Quantity" ] = instrumentQuantity; ! roundTrade[ "EntryDate" ] = startDateTimeOfTrade; ! roundTrade[ "ExitDate" ] = endDateTimeOfTrade; ! roundTrade[ "EntryPrice" ] = entryPrice; ! roundTrade[ "ExitPrice" ] = exitPrice; ! roundTrade[ "%chg" ] = (exitPrice - entryPrice)/entryPrice * 100.0; ! roundTrade[ "%Profit" ] = signForRoundTradeProfit * (double)roundTrade[ "%chg" ]; ! roundTrade[ "Profit" ] = signForRoundTradeProfit * instrumentQuantity * (exitPrice - entryPrice); ! roundTrade[ "#minutes" ] = timeSpanBetweenEnterAndExit.TotalMinutes; ! roundTrade[ "ProfitPerMinute" ] = (double)roundTrade[ "%Profit" ] / (int)roundTrade[ "#minutes" ]; ! roundTradeDataTable.Rows.Add(roundTrade); } + private bool doesCurrentRowIndexPointToABuyLongOrASellShort( int rowIndex ) + { + bool returnValue; + string currentTransactionType = + (string)this.transactionTable.DataTable.Rows[ rowIndex ][fieldNameForTransactionType]; + returnValue = + ( currentTransactionType == "BuyLong" || currentTransactionType == "SellShort" ); + return returnValue; + } private void getRoundTradeTable_setRows( DataTable roundTradeDataTable ) { ! for(int rowIndex = 0; rowIndex < this.transactionTable.DataTable.Rows.Count; rowIndex++ ) ! if( this.doesCurrentRowIndexPointToABuyLongOrASellShort( rowIndex ) ) ! getRoundTradeTable_addRow( rowIndex, ! transactionTable.DataTable.Rows[rowIndex], ! roundTradeDataTable ); } private DataTable getRoundTrades() *************** *** 94,98 **** } #endregion - } } --- 120,123 ---- |