quantproject-developers Mailing List for QuantProject (Page 7)
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
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a4_Fundamentals/RatioProviders In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv16924 Added Files: AverageAndDebtAdjustedGrowthRateProvider.cs LastAvailableGrowthRateProvider.cs LastAvailablePEProvider.cs Log Message: Added classes implementing IGrowthProvider and IRatioProvider_PE interfaces --- NEW FILE: AverageAndDebtAdjustedGrowthRateProvider.cs --- /* QuantProject - Quantitative Finance Library AverageAndDebtAdjustedGrowthRateProvider.cs Copyright (C) 2011 Marco Milletti 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 System.Data; using QuantProject.DataAccess.Tables; using QuantProject.Business.DataProviders; using QuantProject.Business.Financial.Fundamentals; using QuantProject.Business.Financial.Fundamentals.RatioProviders; namespace QuantProject.Business.Financial.Fundamentals.RatioProviders { /// <summary> /// Class implementing IGrowthRateProvider Interface /// It provides an average growth rate, based on past /// incomes and then adjusted by the long term ratio level /// </summary> [Serializable] public class AverageAndDebtAdjustedGrowthRateProvider : FundamentalDataProvider, IGrowthRateProvider { protected double optimalDebtEquityRatio; protected int maximumNumberOfGrowthRatesToTakeIntoAccount; public AverageAndDebtAdjustedGrowthRateProvider( int daysForAvailabilityOfData, int maximumNumberOfGrowthRatesToTakeIntoAccount, double optimalDebtEquityRatio) : base( daysForAvailabilityOfData ) { this.optimalDebtEquityRatio = optimalDebtEquityRatio; this.maximumNumberOfGrowthRatesToTakeIntoAccount = maximumNumberOfGrowthRatesToTakeIntoAccount; } private double getGrowthRate_getLastAvailableDebtEquityRatio( string ticker , DateTime atDate ) { double returnValue = this.optimalDebtEquityRatio; //if not available the given optimalDebtEquityRatio is returned, //so not to bias the estimated average growth rate DateTime limitDateForEndingPeriodDate = atDate.AddDays(- this.daysForAvailabilityOfData); DataTable tableOfDebtEquityRatios = FinancialValues.GetLastFinancialValuesForTicker( ticker, 64, 12, limitDateForEndingPeriodDate);//64 CODE FOR DEBT EQUITY RATIO int numOfRows = tableOfDebtEquityRatios.Rows.Count; if( numOfRows > 0) returnValue = Math.Abs((double)tableOfDebtEquityRatios.Rows[ numOfRows - 1 ]["fvValue"]); return returnValue; } private double[] getGrowthRate_getAverageGrowthRate_getGrowthRates( double[] allAvailableGrowthRates ) { int numOfAvailableGrowthRates = allAvailableGrowthRates.Length; int numOfRatesToTakeIntoAccount = Math.Min(numOfAvailableGrowthRates, this.maximumNumberOfGrowthRatesToTakeIntoAccount); double[] returnValue = new double[numOfRatesToTakeIntoAccount]; for(int i = 0; i < numOfRatesToTakeIntoAccount; i++) { returnValue[i] = allAvailableGrowthRates[numOfAvailableGrowthRates - (numOfRatesToTakeIntoAccount - i)]; } return returnValue; } private double getGrowthRate_getAverageGrowthRate( DataTable tableOfEarnings ) { double returnValue; int numOfRows = tableOfEarnings.Rows.Count; double[] growthRates = new double[ numOfRows - 1 ]; for(int i = 0; i < growthRates.Length ; i++) { growthRates[i] = ( (double)tableOfEarnings.Rows[ i + 1 ]["fvValue"] - (double)tableOfEarnings.Rows[ i ]["fvValue"] ) / (double)tableOfEarnings.Rows[ i ]["fvValue"]; } double[] growthRatesToTakeIntoAccount = this.getGrowthRate_getAverageGrowthRate_getGrowthRates(growthRates); returnValue = ADT.Statistics.BasicFunctions.SimpleAverage(growthRatesToTakeIntoAccount); return returnValue; } public double GetGrowthRate( string ticker , DateTime atDate ) { double returnValue; DateTime limitDateForEndingPeriodDate = atDate.AddDays(- this.daysForAvailabilityOfData); //40 financial code for "net income" DataTable tableOfEarnings = FinancialValues.GetLastFinancialValuesForTicker( ticker, 40, 12, limitDateForEndingPeriodDate); double averageGrowthRate = this.getGrowthRate_getAverageGrowthRate(tableOfEarnings); double lastAvailableDebtEquityRatio = this.getGrowthRate_getLastAvailableDebtEquityRatio(ticker, atDate); returnValue = averageGrowthRate * Math.Min(1.0, (this.optimalDebtEquityRatio / lastAvailableDebtEquityRatio ) ); return returnValue; } } } --- NEW FILE: LastAvailablePEProvider.cs --- /* QuantProject - Quantitative Finance Library LastAvailablePEProvider.cs Copyright (C) 2010 Marco Milletti 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.DataAccess.Tables; using QuantProject.Business.DataProviders; using QuantProject.Business.Financial.Fundamentals; using QuantProject.Business.Financial.Fundamentals.RatioProviders; namespace QuantProject.Business.Financial.Fundamentals.RatioProviders { /// <summary> /// Class implementing IRatioProvider_PE Interface /// It provides the last available PE, using the last available price /// and the last available Earnings. /// Instead of the last available price, /// the average of the last available prices can be used /// (it depends on how the class has been instatiated) /// </summary> [Serializable] public class LastAvailablePEProvider : FundamentalDataProvider, IRatioProvider_PE { private HistoricalMarketValueProvider historicalmarketValueProvider; public LastAvailablePEProvider(HistoricalMarketValueProvider historicalmarketValueProvider, int daysForAvailabilityOfData) : base(daysForAvailabilityOfData) { this.historicalmarketValueProvider = historicalmarketValueProvider; } private double getPERatio_getLastAvailableEarningsPerShare(string ticker , DateTime atDate) { double returnValue; DateTime limitDateForEndingPeriodDate = atDate.AddDays(- this.daysForAvailabilityOfData); //56 code for EPS; 12 months = length of period financial value refers to returnValue = FinancialValues.GetLastFinancialValueForTicker(ticker, 56, 12, limitDateForEndingPeriodDate); return returnValue; } public double GetPERatio( string ticker , DateTime atDate ) { double returnValue; double priceAtDate = this.historicalmarketValueProvider.GetMarketValue(ticker, atDate); double earningsPerShareAtDate = this.getPERatio_getLastAvailableEarningsPerShare(ticker , atDate); returnValue = priceAtDate / earningsPerShareAtDate; return returnValue; } } } --- NEW FILE: LastAvailableGrowthRateProvider.cs --- /* QuantProject - Quantitative Finance Library LastAvailableGrowthRateProvider.cs Copyright (C) 2010 Marco Milletti 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 System.Data; using QuantProject.DataAccess.Tables; using QuantProject.Business.DataProviders; using QuantProject.Business.Financial.Fundamentals; using QuantProject.Business.Financial.Fundamentals.RatioProviders; namespace QuantProject.Business.Financial.Fundamentals.RatioProviders { /// <summary> /// Class implementing IGrowthRateProvider Interface /// It provides the last available growth rate (of earnings) /// </summary> [Serializable] public class LastAvailableGrowthRateProvider : FundamentalDataProvider, IGrowthRateProvider { public LastAvailableGrowthRateProvider( int daysForAvailabilityOfData ) : base( daysForAvailabilityOfData ) { } public double GetGrowthRate( string ticker , DateTime atDate ) { double returnValue; double lastEarnings; double previousEarnings; DateTime limitDateForEndingPeriodDate = atDate.AddDays(- this.daysForAvailabilityOfData); //40 financial code for "net income" DataTable tableOfEarnings = FinancialValues.GetLastFinancialValuesForTicker( ticker, 40, 12, limitDateForEndingPeriodDate); int numOfRows = tableOfEarnings.Rows.Count; previousEarnings = (double)tableOfEarnings.Rows[numOfRows - 2]["fvValue"]; lastEarnings = (double)tableOfEarnings.Rows[numOfRows - 1]["fvValue"]; returnValue = (lastEarnings - previousEarnings)/previousEarnings; return returnValue; } } } |
|
From: Marco M. <mi...@us...> - 2011-01-16 18:59:50
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a4_Fundamentals/RatioProviders In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv15881 Added Files: IGrowthRateProvider.cs IRatioProvider_PE.cs Log Message: Added IGrowthProvider and IRatioProvider_PE interfaces --- NEW FILE: IGrowthRateProvider.cs --- /* QuantProject - Quantitative Finance Library IGrowthRateProvider.cs Copyright (C) 2010 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*/ using System; namespace QuantProject.Business.Financial.Fundamentals.RatioProviders { /// <summary> /// Interface to be implemented by objects implementing a model which provides /// the growth rate for a given ticker, using /// available fundamental data since another previous date /// </summary> public interface IGrowthRateProvider { double GetGrowthRate( string ticker , DateTime atDate ); } } --- NEW FILE: IRatioProvider_PE.cs --- /* QuantProject - Quantitative Finance Library IRatioProvider_PE.cs Copyright (C) 2010 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*/ using System; namespace QuantProject.Business.Financial.Fundamentals.RatioProviders { /// <summary> /// Interface to be implemented by objects implementing a way of computing /// the popular PE Ratio /// </summary> public interface IRatioProvider_PE { double GetPERatio( string ticker , DateTime atDate ); } } |
|
From: Marco M. <mi...@us...> - 2011-01-16 18:42:45
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a4_Fundamentals/FairValueProviders In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv10368 Added Files: IFairValueProvider.cs PEGRatioFairValueProvider.cs Log Message: Added IFairValueProvider interface and PEGRatioFairValueProvider implementing it --- NEW FILE: IFairValueProvider.cs --- /* QuantProject - Quantitative Finance Library IFairValueProvider.cs Copyright (C) 2010 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*/ using System; namespace QuantProject.Business.Financial.Fundamentals.FairValueProviders { /// <summary> /// Interface to be implemented by objects implementing a model which computes /// the fair value for a given ticker at a given date, using /// available fundamental data since another previous date /// </summary> public interface IFairValueProvider { double GetFairValue( string ticker , DateTime firstDateForFundamentals, DateTime dateOfFairValueComputation ); } } --- NEW FILE: PEGRatioFairValueProvider.cs --- /* QuantProject - Quantitative Finance Library PEGRatioFairValueProvider.cs Copyright (C) 2010 Marco Milletti 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.DataProviders; using QuantProject.Business.Financial.Fundamentals; using QuantProject.Business.Financial.Fundamentals.RatioProviders; namespace QuantProject.Business.Financial.Fundamentals.FairValueProviders { /// <summary> /// Class implementing IFairValueProvider Interface /// using the popular PEG ratio (P/E ratio divided by an expected /// growth rate) /// </summary> [Serializable] public class PEGRatioFairValueProvider : IFairValueProvider { private double fairPEGRatioLevel; private IRatioProvider_PE ratioProvider_PE; private IGrowthRateProvider growthRateProvider; private HistoricalMarketValueProvider historicalMarketValueProvider; public PEGRatioFairValueProvider(double fairPEGRatioLevel, IRatioProvider_PE ratioProvider_PE, IGrowthRateProvider growthRateProvider, HistoricalMarketValueProvider historicalMarketValueProvider) { this.fairPEGRatioLevel = fairPEGRatioLevel; this.ratioProvider_PE = ratioProvider_PE; this.growthRateProvider = growthRateProvider; this.historicalMarketValueProvider = historicalMarketValueProvider; } private double getPEGRatio(string ticker , DateTime firstDateForFundamentals, DateTime dateOfFairValueComputation) { double returnValue; double growthRate = this.growthRateProvider.GetGrowthRate(ticker, dateOfFairValueComputation); double PE = this.ratioProvider_PE.GetPERatio(ticker, dateOfFairValueComputation); if(growthRate < 0) returnValue = double.MaxValue; else returnValue = PE / (100.0 * growthRate); return returnValue; } public double GetFairValue( string ticker , DateTime firstDateForFundamentals, DateTime dateOfFairValueComputation ) { double returnValue; double priceAtDateOfFairValueComputation = this.historicalMarketValueProvider.GetMarketValue(ticker, dateOfFairValueComputation); returnValue = priceAtDateOfFairValueComputation * this.fairPEGRatioLevel / this.getPEGRatio(ticker, firstDateForFundamentals, dateOfFairValueComputation); return returnValue; } } } |
|
From: Marco M. <mi...@us...> - 2011-01-16 18:38:09
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a4_Fundamentals/RatioProviders In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv8863/RatioProviders Log Message: Directory /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a4_Fundamentals/RatioProviders added to the repository |
|
From: Marco M. <mi...@us...> - 2011-01-16 18:37:52
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a4_Fundamentals/FairValueProviders In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv8808/FairValueProviders Log Message: Directory /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a4_Fundamentals/FairValueProviders added to the repository |
|
From: Marco M. <mi...@us...> - 2011-01-16 18:34:30
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Eligibles In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv7575/a2_Strategies/Eligibles Modified Files: ByMostDiscountedPrices.cs Log Message: Updated ByMostDiscountedPrices IEligiblesSelectors Index: ByMostDiscountedPrices.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Eligibles/ByMostDiscountedPrices.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ByMostDiscountedPrices.cs 20 Nov 2010 18:55:41 -0000 1.1 --- ByMostDiscountedPrices.cs 16 Jan 2011 18:34:18 -0000 1.2 *************** *** 29,33 **** using QuantProject.Data.DataTables; using QuantProject.Data.Selectors; ! using QuantProject.Business.Financial.Fundamentals; namespace QuantProject.Business.Strategies.Eligibles --- 29,33 ---- using QuantProject.Data.DataTables; using QuantProject.Data.Selectors; ! using QuantProject.Business.Financial.Fundamentals.FairValueProviders; namespace QuantProject.Business.Strategies.Eligibles *************** *** 40,50 **** /// are returned depending on the time the selection is requested: /// the group SP 500 should be like that); ! /// -step 2: from tickers selected by step 1, the ones /// (not more than a given max number) that have ! /// the greatest (negative) relative difference between the current price ! /// and the fair price; /// </summary> [Serializable] ! public class ByMostDiscountedPrices : IEligiblesSelector { public event NewMessageEventHandler NewMessage; --- 40,54 ---- /// are returned depending on the time the selection is requested: /// the group SP 500 should be like that); ! /// -step 2: from tickers selected by step 1, only the ones ! /// that have incomes greater than a given minimum in the ! /// last given times, in a row ! /// -step 3: from tickers selected by step 2, the ones /// (not more than a given max number) that have ! /// the greatest relative difference between the fair price ! /// (provided by a IFairValueProvider) and the average price ! /// computed for a given number of days /// </summary> [Serializable] ! public class ByMostDiscountedPrices : IEligiblesSelector { public event NewMessageEventHandler NewMessage; *************** *** 55,58 **** --- 59,67 ---- private int numOfDaysForFundamentalAnalysis; private IFairValueProvider fairValueProvider; + private int numDaysForFundamentalDataAvailability; + private double minimumIncome; + private int numberOfMinGrowingIncomesInARowForTickers; + private double minimumRelativeDifferenceBetweenFairAndAverageMarketPrice; + private int numOfDaysForAverageMarketPriceComputation; public string Description *************** *** 68,72 **** public ByMostDiscountedPrices(IFairValueProvider fairValueProvider, string tickersGroupID , bool temporizedGroup, ! int maxNumberOfEligibleTickersToBeChosen, int numOfDaysForFundamentalAnalysis) { this.fairValueProvider = fairValueProvider; --- 77,85 ---- public ByMostDiscountedPrices(IFairValueProvider fairValueProvider, string tickersGroupID , bool temporizedGroup, ! int maxNumberOfEligibleTickersToBeChosen, int numOfDaysForFundamentalAnalysis, ! int numDaysForFundamentalDataAvailability, double minimumIncome, ! int numberOfMinGrowingIncomesInARowForTickers, ! double minimumRelativeDifferenceBetweenFairAndAverageMarketPrice, ! int numOfDaysForAverageMarketPriceComputation) { this.fairValueProvider = fairValueProvider; *************** *** 76,79 **** --- 89,101 ---- this.tickersGroupID = tickersGroupID; this.numOfDaysForFundamentalAnalysis = numOfDaysForFundamentalAnalysis; + this.numDaysForFundamentalDataAvailability = + numDaysForFundamentalDataAvailability; + this.minimumIncome = minimumIncome; + this.numberOfMinGrowingIncomesInARowForTickers = + numberOfMinGrowingIncomesInARowForTickers; + this.minimumRelativeDifferenceBetweenFairAndAverageMarketPrice = + minimumRelativeDifferenceBetweenFairAndAverageMarketPrice; + this.numOfDaysForAverageMarketPriceComputation = + numOfDaysForAverageMarketPriceComputation; } *************** *** 81,107 **** DataTable initialTableFromWhichToChooseTheMostDiscountedTickers, DateTime date ) { DataTable tableOfEligibleTickers; if(!initialTableFromWhichToChooseTheMostDiscountedTickers.Columns.Contains("FairPrice")) initialTableFromWhichToChooseTheMostDiscountedTickers.Columns.Add("FairPrice", System.Type.GetType("System.Double")); ! if(!initialTableFromWhichToChooseTheMostDiscountedTickers.Columns.Contains("MarketPrice")) ! initialTableFromWhichToChooseTheMostDiscountedTickers.Columns.Add("LastMonthAverageMarketPrice", System.Type.GetType("System.Double")); if(!initialTableFromWhichToChooseTheMostDiscountedTickers.Columns.Contains("RelativeDifferenceBetweenFairAndMarketPrice")) initialTableFromWhichToChooseTheMostDiscountedTickers.Columns.Add("RelativeDifferenceBetweenFairAndMarketPrice", System.Type.GetType("System.Double")); foreach(DataRow row in initialTableFromWhichToChooseTheMostDiscountedTickers.Rows) { ! row["FairPrice"] = ! this.fairValueProvider.GetFairValue( (string)row[0], ! date.AddDays(-this.numOfDaysForFundamentalAnalysis), ! date ); ! float[] lastMonthQuotes = ! Quotes.GetArrayOfAdjustedCloseQuotes((string)row[0], date.AddDays(-30), date); ! row["LastMonthAverageMarketPrice"] = ! ADT.Statistics.BasicFunctions.SimpleAverage(lastMonthQuotes); ! row["RelativeDifferenceBetweenFairAndMarketPrice"] = ! ((double)row["FairPrice"]-(double)row["LastMonthAverageMarketPrice"])/(double)row["FairPrice"]; } ! tableOfEligibleTickers = ExtendedDataTable.CopyAndSort(initialTableFromWhichToChooseTheMostDiscountedTickers, ! "RelativeDifferenceBetweenFairAndMarketPrice", true); ExtendedDataTable.DeleteRows(tableOfEligibleTickers, this.maxNumberOfEligibleTickersToBeChosen); --- 103,147 ---- DataTable initialTableFromWhichToChooseTheMostDiscountedTickers, DateTime date ) { + double signOfCurrentFairPrice; + double currentFairPrice; DataTable tableOfEligibleTickers; if(!initialTableFromWhichToChooseTheMostDiscountedTickers.Columns.Contains("FairPrice")) initialTableFromWhichToChooseTheMostDiscountedTickers.Columns.Add("FairPrice", System.Type.GetType("System.Double")); ! if(!initialTableFromWhichToChooseTheMostDiscountedTickers.Columns.Contains("AverageMarketPrice")) ! initialTableFromWhichToChooseTheMostDiscountedTickers.Columns.Add("AverageMarketPrice", System.Type.GetType("System.Double")); if(!initialTableFromWhichToChooseTheMostDiscountedTickers.Columns.Contains("RelativeDifferenceBetweenFairAndMarketPrice")) initialTableFromWhichToChooseTheMostDiscountedTickers.Columns.Add("RelativeDifferenceBetweenFairAndMarketPrice", System.Type.GetType("System.Double")); foreach(DataRow row in initialTableFromWhichToChooseTheMostDiscountedTickers.Rows) { ! try{ ! currentFairPrice = this.fairValueProvider.GetFairValue( (string)row[0], ! date.AddDays(-this.numOfDaysForFundamentalAnalysis), ! date ); ! row["FairPrice"] = currentFairPrice; ! double[] quotesForAveragePriceComputation = ! Quotes.GetDoubleArrayOfAdjustedCloseQuotes((string)row[0], date.AddDays(-this.numOfDaysForAverageMarketPriceComputation), date); ! row["AverageMarketPrice"] = ! ADT.Statistics.BasicFunctions.SimpleAverage(quotesForAveragePriceComputation); ! if(currentFairPrice < 0.0) ! signOfCurrentFairPrice = -1.0; ! else ! signOfCurrentFairPrice = 1.0; ! row["RelativeDifferenceBetweenFairAndMarketPrice"] = signOfCurrentFairPrice * ! ((double)row["FairPrice"]-(double)row["AverageMarketPrice"])/(double)row["AverageMarketPrice"]; ! } ! catch(Exception ex) ! { ! string s = ex.ToString(); ! } } ! string filterString = ! "AverageMarketPrice is not null AND FairPrice is not null AND " + ! "RelativeDifferenceBetweenFairAndMarketPrice >" + ! this.minimumRelativeDifferenceBetweenFairAndAverageMarketPrice.ToString(); ! ! tableOfEligibleTickers = ExtendedDataTable.CopyAndSort(initialTableFromWhichToChooseTheMostDiscountedTickers, ! filterString, ! "RelativeDifferenceBetweenFairAndMarketPrice", false); ExtendedDataTable.DeleteRows(tableOfEligibleTickers, this.maxNumberOfEligibleTickersToBeChosen); *************** *** 127,132 **** group = new SelectorByGroup(this.tickersGroupID); DataTable tickersFromGroup = group.GetTableOfSelectedTickers(); ! return this.getEligibleTickers_actually_getTableOfMostDiscountedTickers(tickersFromGroup, currentDate); } --- 167,179 ---- group = new SelectorByGroup(this.tickersGroupID); DataTable tickersFromGroup = group.GetTableOfSelectedTickers(); + SelectorByNumOfMinGrowingIncomesInARow selectorByMinimumGrowingIncomes = + new SelectorByNumOfMinGrowingIncomesInARow(tickersFromGroup, history.FirstDateTime, + history.LastDateTime, + this.minimumIncome, this.numberOfMinGrowingIncomesInARowForTickers, + 12, this.numDaysForFundamentalDataAvailability); + DataTable tickersWithPositiveGrowingIncomes = + selectorByMinimumGrowingIncomes.GetTableOfSelectedTickers(); ! return this.getEligibleTickers_actually_getTableOfMostDiscountedTickers(tickersWithPositiveGrowingIncomes, currentDate); } |
|
From: Marco M. <mi...@us...> - 2011-01-16 18:31:29
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Eligibles In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv6803/a2_Strategies/Eligibles Added Files: ByGroup.cs ByLiquidity.cs Log Message: Added ByGroup and ByLiquidity classes, implementing IEligiblesSelector interface --- NEW FILE: ByLiquidity.cs --- /* QuantProject - Quantitative Finance Library ByLiquidity.cs Copyright (C) 2011 Marco Milletti 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 System.Data; using QuantProject.ADT.Histories; using QuantProject.ADT.Messaging; using QuantProject.Data.Selectors; namespace QuantProject.Business.Strategies.Eligibles { /// <summary> /// Implements IEligiblesSelector for selecting a given max number of tickers through /// the following step-by-step selecting process: /// -step 1: all tickers belonging to a given group /// are selected (the group can be "temporized": that is tickers /// are returned depending on the time the selection is requested: /// the group SP 500 should be like that); /// -step 2: from tickers selected by step 1, the most liquid /// are selected (not more than a given max number); /// </summary> [Serializable] public class ByLiquidity : IEligiblesSelector { public event NewMessageEventHandler NewMessage; private bool temporizedGroup; private string tickersGroupID; private int maxNumberOfEligibleTickersToBeChosen; public string Description { get{ return "From_" + this.tickersGroupID + " (temporized: " + this.temporizedGroup.ToString() + ")\n" + "MaxNumOfEligibles_" + this.maxNumberOfEligibleTickersToBeChosen.ToString() + "\n" + "Most Liquid for the in sample time frame"; } } public ByLiquidity( string tickersGroupID , bool temporizedGroup, int maxNumberOfEligibleTickersToBeChosen) { this.temporizedGroup = temporizedGroup; this.tickersGroupID = tickersGroupID; this.maxNumberOfEligibleTickersToBeChosen = maxNumberOfEligibleTickersToBeChosen; } private EligibleTickers getEligibleTickers_actually( History history ) { DateTime currentDate = history.LastDateTime; SelectorByGroup group; if(this.temporizedGroup) //the group is "temporized": returned set of tickers // depend on time group = new SelectorByGroup(this.tickersGroupID, currentDate); else//the group is not temporized group = new SelectorByGroup(this.tickersGroupID); DataTable tickersFromGroup = group.GetTableOfSelectedTickers(); SelectorByLiquidity mostLiquidSelector = new SelectorByLiquidity( tickersFromGroup , false, history.FirstDateTime, currentDate, this.maxNumberOfEligibleTickersToBeChosen); DataTable dataTableToBeReturned = mostLiquidSelector.GetTableOfSelectedTickers(); // DataSet dataSet = new DataSet(); // dataSet.Tables.Add( dataTableMostLiquid ); // dataSet.WriteXml( "c:\\qpReports\\pairsTrading\\eligiblesCon_ByPriceMostLiquidAlwaysQuoted.xml" ); return new EligibleTickers( dataTableToBeReturned ); } private void getEligibleTickers_sendNewMessage( EligibleTickers eligibleTickers ) { string message = "Number of Eligible tickers: " + eligibleTickers.Count; NewMessageEventArgs newMessageEventArgs = new NewMessageEventArgs( message ); if(this.NewMessage != null) this.NewMessage( this , newMessageEventArgs ); } /// <summary> /// Returns the eligible tickers /// </summary> /// <returns></returns> public EligibleTickers GetEligibleTickers( History history ) { EligibleTickers eligibleTickers = this.getEligibleTickers_actually( history ); this.getEligibleTickers_sendNewMessage( eligibleTickers ); return eligibleTickers; } } } --- NEW FILE: ByGroup.cs --- /* QuantProject - Quantitative Finance Library ByGroup.cs Copyright (C) 2011 Marco Milletti 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 System.Data; using QuantProject.ADT.Histories; using QuantProject.ADT.Messaging; using QuantProject.Data.Selectors; namespace QuantProject.Business.Strategies.Eligibles { /// <summary> /// Implements IEligiblesSelector for selecting all the tickers /// belonging to a given group /// </summary> [Serializable] public class ByGroup : IEligiblesSelector { public event NewMessageEventHandler NewMessage; private bool temporizedGroup; private string tickersGroupID; public string Description { get{ return "From_" + this.tickersGroupID + " (temporized: " + this.temporizedGroup.ToString() + ")"; } } public ByGroup( string tickersGroupID , bool temporizedGroup) { this.temporizedGroup = temporizedGroup; this.tickersGroupID = tickersGroupID; } private EligibleTickers getEligibleTickers_actually( History history ) { DateTime currentDate = history.LastDateTime; SelectorByGroup group; if(this.temporizedGroup) //the group is "temporized": returned set of tickers // depend on time group = new SelectorByGroup(this.tickersGroupID, currentDate); else//the group is not temporized group = new SelectorByGroup(this.tickersGroupID); DataTable tickersFromGroup = group.GetTableOfSelectedTickers(); // DataSet dataSet = new DataSet(); // dataSet.Tables.Add( dataTableMostLiquid ); // dataSet.WriteXml( "c:\\qpReports\\pairsTrading\\eligiblesCon_ByPriceMostLiquidAlwaysQuoted.xml" ); return new EligibleTickers( tickersFromGroup ); } private void getEligibleTickers_sendNewMessage( EligibleTickers eligibleTickers ) { string message = "Number of Eligible tickers: " + eligibleTickers.Count; NewMessageEventArgs newMessageEventArgs = new NewMessageEventArgs( message ); if(this.NewMessage != null) this.NewMessage( this , newMessageEventArgs ); } /// <summary> /// Returns the eligible tickers /// </summary> /// <returns></returns> public EligibleTickers GetEligibleTickers( History history ) { EligibleTickers eligibleTickers = this.getEligibleTickers_actually( history ); this.getEligibleTickers_sendNewMessage( eligibleTickers ); return eligibleTickers; } } } |
|
From: Marco M. <mi...@us...> - 2011-01-16 18:28:26
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataTables In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv5482/DataTables Modified Files: Quotes.cs Log Message: Added GetDoubleArrayOfAdjustedCloseQuotes method Index: Quotes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataTables/Quotes.cs,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** Quotes.cs 29 Mar 2009 18:35:36 -0000 1.39 --- Quotes.cs 16 Jan 2011 18:28:18 -0000 1.40 *************** *** 671,674 **** --- 671,682 ---- return ExtendedDataTable.GetArrayOfFloatFromColumn(tickerQuotes,"quAdjustedClose"); } + public static double[] GetDoubleArrayOfAdjustedCloseQuotes(string ticker, + DateTime firstQuoteDate, + DateTime lastQuoteDate) + { + Quotes tickerQuotes = new Quotes(ticker, firstQuoteDate, lastQuoteDate); + return ExtendedDataTable.GetArrayOfDoubleFromColumn(tickerQuotes,"quAdjustedClose"); + } + #region GetAdjustedCloseHistory private static History getAdjustedCloseHistory( Quotes tickerQuotes ) |
Update of /cvsroot/quantproject/QuantProject/b3_Data/Selectors In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv4883/Selectors Added Files: SelectorByNumberOfMinimumIncomesInARow.cs SelectorByNumOfMinGrowingIncomesInARow.cs SelectorByPriceAndFairValueComparison.cs Log Message: Added Selectors by (very simple, at the moment) fundamental analysis --- NEW FILE: SelectorByPriceAndFairValueComparison.cs --- /* QuantProject - Quantitative Finance Library SelectorByPriceAndFairValueComparison.cs Copyright (C) 2010 Marco Milletti 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 System.Collections; using System.Data; using System.Windows.Forms; using QuantProject.DataAccess.Tables; using QuantProject.Data.DataTables; using QuantProject. namespace QuantProject.Data.Selectors { /// <summary> /// Class for selection on tickers by the relative difference /// between price and fair value computed by the given /// IFairValueProvider /// </summary> public class SelectorByPriceAndFairValueComparison : TickerSelector, ITickerSelector { private IFairValueProvider fairValueProvider; #region SelectorByPriceAndFairValueComparison Constructors /// <summary> /// ITickerSelector class for selecting tickers /// by the relative difference /// between price and fair value computed by the given /// IFairValueProvider /// </summary> /// <param name="fairValueProvider">IFairValueProvider object, /// which provides fair value computation for a given /// tickers at a given date</param> /// <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="firstDateForFundamentalAnalysis"></param> /// <param name="lastDateForFundamentalAnalysis"></param> /// <param name="maxNumOfReturnedTickers">Max number of selected /// tickers to be returned</param> /// <returns></returns> public SelectorByPriceAndFairValueComparison(IFairValueProvider fairValueProvider, DataTable setOfTickersToBeSelected, bool orderInASCmode, DateTime firstDateForFundamentalAnalysis, DateTime lastDateForFundamentalAnalysis, long maxNumOfReturnedTickers): base(setOfTickersToBeSelected, orderInASCmode, firstDateForFundamentalAnalysis, firstDateForFundamentalAnalysis, maxNumOfReturnedTickers) { this.fairValueProvider = fairValueProvider; } #endregion SelectorByLiquidityConstructors public DataTable GetTableOfSelectedTickers() { DataTable returnTickers; if(this.setOfTickersToBeSelected == null) { if ( this.minVolume > long.MinValue ) // a min volume value has been requested returnTickers = QuantProject.DataAccess.Tables.Quotes.GetTickersByLiquidity(this.isOrderedInASCMode, this.groupID, this.firstQuoteDate, this.lastQuoteDate, this.minVolume , this.maxNumOfReturnedTickers); else // a min volume value has not been requested returnTickers = QuantProject.DataAccess.Tables.Quotes.GetTickersByLiquidity(this.isOrderedInASCMode, this.groupID, this.firstQuoteDate, this.lastQuoteDate, this.maxNumOfReturnedTickers); } else//a set of tickers, not a group ID, //has been passed to the selector { if ( this.minVolume > long.MinValue ) // a min volume value has been requested returnTickers = QuantProject.Data.DataTables.Quotes.GetTickersByLiquidity(this.isOrderedInASCMode, this.setOfTickersToBeSelected, this.firstQuoteDate, this.lastQuoteDate, this.minVolume, this.maxNumOfReturnedTickers, this.numberOfTopRowsToDelete); else returnTickers = QuantProject.Data.DataTables.Quotes.GetTickersByLiquidity(this.isOrderedInASCMode, this.setOfTickersToBeSelected, this.firstQuoteDate, this.lastQuoteDate, this.maxNumOfReturnedTickers, this.numberOfTopRowsToDelete); } return returnTickers; } public void SelectAllTickers() { ; } } } --- NEW FILE: SelectorByNumberOfMinimumIncomesInARow.cs --- /* QuantProject - Quantitative Finance Library SelectorByNumberOfMinimumIncomesInARow.cs Copyright (C) 2010 Marco Milletti 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 System.Collections; using System.Data; using System.Windows.Forms; using QuantProject.ADT.Histories; using QuantProject.DataAccess.Tables; using QuantProject.Data.DataTables; namespace QuantProject.Data.Selectors { /// <summary> /// Class for selection on tickers which have a given number of /// minimum incomes previously than a given date /// </summary> public class SelectorByNumberOfMinimumIncomesInARow : TickerSelector , ITickerSelector { private double minimumIncome; private int numberOfIncomes; private int incomePeriodLengthInMonths; private int numDaysForFundamentalDataAvailability; public SelectorByNumberOfMinimumIncomesInARow(DataTable setOfTickersToBeSelected, DateTime firstQuoteDate, DateTime lastQuoteDate, double minimumIncome, int numberOfIncomes, int incomePeriodLengthInMonths, int numDaysForFundamentalDataAvailability): base(setOfTickersToBeSelected, true, firstQuoteDate, lastQuoteDate, 500) { this.minimumIncome = minimumIncome; this.numberOfIncomes = numberOfIncomes; this.incomePeriodLengthInMonths = incomePeriodLengthInMonths; this.numDaysForFundamentalDataAvailability = numDaysForFundamentalDataAvailability; } #region GetTableOfSelectedTickers private bool getTableOfSelectedTickers_areIncomesAllGreaterThanMinimum(DataTable incomesForTicker) { bool returnValue = true; double currentIncome; for(int i = 0; i < incomesForTicker.Rows.Count; i++) { currentIncome = (double)incomesForTicker.Rows[i]["fvValue"]; if( currentIncome < this.minimumIncome ) returnValue = false; } return returnValue; } public DataTable GetTableOfSelectedTickers() { DataTable returnValue = new DataTable(); returnValue.Columns.Add("Ticker", System.Type.GetType("System.String")); object[] values = new object[1]; string currentTicker; DataTable incomesForCurrentTicker; for(int i = 0; i < this.setOfTickersToBeSelected.Rows.Count; i++) { currentTicker = (string)this.setOfTickersToBeSelected.Rows[i][0]; incomesForCurrentTicker = FinancialValues.GetLastFinancialValuesForTicker(currentTicker, 40, 12, this.lastQuoteDate.AddDays(-this.numDaysForFundamentalDataAvailability)); if( this.getTableOfSelectedTickers_areIncomesAllGreaterThanMinimum(incomesForCurrentTicker) ) { values[0] = currentTicker; returnValue.Rows.Add(values); } } return returnValue; } #endregion GetTableOfSelectedTickers public void SelectAllTickers() { ; } } } --- NEW FILE: SelectorByNumOfMinGrowingIncomesInARow.cs --- /* QuantProject - Quantitative Finance Library SelectorByNumOfMinGrowingIncomesInARow.cs Copyright (C) 2010 Marco Milletti 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 System.Collections; using System.Data; using System.Windows.Forms; using QuantProject.ADT.Histories; using QuantProject.DataAccess.Tables; using QuantProject.Data.DataTables; namespace QuantProject.Data.Selectors { /// <summary> /// Class for selection on tickers which have a given number of /// minimum incomes, always growing, previously than a given date /// </summary> public class SelectorByNumOfMinGrowingIncomesInARow : TickerSelector , ITickerSelector { private double minimumIncome; private int numberOfIncomes; private int incomePeriodLengthInMonths; private int numDaysForFundamentalDataAvailability; public SelectorByNumOfMinGrowingIncomesInARow(DataTable setOfTickersToBeSelected, DateTime firstQuoteDate, DateTime lastQuoteDate, double minimumIncome, int numberOfIncomes, int incomePeriodLengthInMonths, int numDaysForFundamentalDataAvailability): base(setOfTickersToBeSelected, true, firstQuoteDate, lastQuoteDate, 500) { this.minimumIncome = minimumIncome; this.numberOfIncomes = numberOfIncomes; this.incomePeriodLengthInMonths = incomePeriodLengthInMonths; this.numDaysForFundamentalDataAvailability = numDaysForFundamentalDataAvailability; } #region GetTableOfSelectedTickers private bool getTableOfSelectedTickers_areIncomesAllGreaterThanMinimum(DataTable incomesForTicker) { bool returnValue = true; double previousIncome; double currentIncome = this.minimumIncome; for(int i = 0; i < incomesForTicker.Rows.Count; i++) { previousIncome = currentIncome; currentIncome = (double)incomesForTicker.Rows[i]["fvValue"]; if( currentIncome < this.minimumIncome || currentIncome < previousIncome ) returnValue = false; } return returnValue; } public DataTable GetTableOfSelectedTickers() { DataTable returnValue = new DataTable(); returnValue.Columns.Add("Ticker", System.Type.GetType("System.String")); object[] values = new object[1]; string currentTicker; DataTable incomesForCurrentTicker; for(int i = 0; i < this.setOfTickersToBeSelected.Rows.Count; i++) { currentTicker = (string)this.setOfTickersToBeSelected.Rows[i][0]; incomesForCurrentTicker = FinancialValues.GetLastFinancialValuesForTicker(currentTicker, 40, 12, this.lastQuoteDate.AddDays(-this.numDaysForFundamentalDataAvailability)); if( this.getTableOfSelectedTickers_areIncomesAllGreaterThanMinimum(incomesForCurrentTicker) ) { values[0] = currentTicker; returnValue.Rows.Add(values); } } return returnValue; } #endregion GetTableOfSelectedTickers public void SelectAllTickers() { ; } } } |
|
From: Marco M. <mi...@us...> - 2011-01-16 18:10:38
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv31767 Modified Files: FinancialValues.cs Log Message: Added methods for retrieving fundamentals (financial values) for tickers Index: FinancialValues.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables/FinancialValues.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FinancialValues.cs 20 Nov 2010 19:01:00 -0000 1.1 --- FinancialValues.cs 16 Jan 2011 18:10:30 -0000 1.2 *************** *** 49,53 **** this.financialValues = FinancialValues.GetTickerFinancialValues( ticker, periodLengthInMonths ); } ! /// <summary> /// It provides addition of the given financial values into table "financial values" --- 49,53 ---- this.financialValues = FinancialValues.GetTickerFinancialValues( ticker, periodLengthInMonths ); } ! /// <summary> /// It provides addition of the given financial values into table "financial values" *************** *** 73,77 **** } } ! /// <summary> /// returns the financial values DataTable for the given ticker --- 73,145 ---- } } ! ! /// <summary> ! /// Returns last available financial value for the given ticker ! /// </summary> ! /// <param name="ticker"></param> ! /// <param name="financialDataCode">Code for the financial value ! /// - stored in DB table </param> ! /// <param name="atDate">Last financial value at the first immediate ! /// date previous than param atDate will be returned</param> ! /// <returns></returns> ! public static double GetLastFinancialValueForTicker( string ticker, int financialDataCode, ! int periodLengthInMonths, ! DateTime atDate ) ! { ! string sqlString = "select * from financialValues where fvTiTicker='" + ticker + "' " + ! "AND fvFdId=" + financialDataCode + " " + ! "AND fvPeriodLengthInMonths=" + periodLengthInMonths + " " + ! "AND fvEndingPeriodDate<" + SQLBuilder.GetDateConstant(atDate) + " " + ! "order by fvEndingPeriodDate"; ! DataTable dataTable = SqlExecutor.GetDataTable(sqlString); ! int numOfRows = dataTable.Rows.Count; ! ! return (double)(dataTable.Rows[ numOfRows - 1 ][ "fvValue" ]); ! } ! /// <summary> ! /// Returns last available financial values for the given ticker ! /// </summary> ! /// <param name="ticker"></param> ! /// <param name="financialDataCode">Code for the financial value ! /// - stored in DB table </param> ! /// <param name="atDate">Last financial values with endingPeriodDate ! /// previous than param atDate will be returned</param> ! /// <returns></returns> ! public static DataTable GetLastFinancialValuesForTicker( string ticker, int financialDataCode, ! int periodLengthInMonths, ! DateTime atDate ) ! { ! string sqlString = "select * from financialValues where fvTiTicker='" + ticker + "' " + ! "AND fvFdId=" + financialDataCode + " " + ! "AND fvPeriodLengthInMonths=" + periodLengthInMonths + " " + ! "AND fvEndingPeriodDate<" + SQLBuilder.GetDateConstant(atDate) + " " + ! "order by fvEndingPeriodDate"; ! ! DataTable dataTable = SqlExecutor.GetDataTable(sqlString); ! ! return dataTable; ! } ! /// <summary> ! /// Returns last available financial values for all tickers ! /// </summary> ! /// <param name="financialDataCode">Code for the financial value ! /// - stored in DB table </param> ! /// <param name="atDate">Last financial values with endingPeriodDate ! /// previous than param atDate will be returned</param> ! /// <returns></returns> ! public static DataTable GetLastFinancialValues(int financialDataCode, ! int periodLengthInMonths, ! DateTime atDate ) ! { ! string sqlString = "select * from financialValues where fvFdId=" + financialDataCode + " " + ! "AND fvPeriodLengthInMonths=" + periodLengthInMonths + " " + ! "AND fvEndingPeriodDate<" + SQLBuilder.GetDateConstant(atDate) + " " + ! "order by fvEndingPeriodDate"; ! ! DataTable dataTable = SqlExecutor.GetDataTable(sqlString); ! ! return dataTable; ! } ! /// <summary> /// returns the financial values DataTable for the given ticker |
|
From: Marco M. <mi...@us...> - 2011-01-16 11:21:37
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv26948 Modified Files: TickerDownloader.cs Log Message: Fixed bug: now the TickerDownloader properly updates new adjusted values in DB Index: TickerDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/TickerDownloader.cs,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** TickerDownloader.cs 30 Dec 2008 00:18:26 -0000 1.23 --- TickerDownloader.cs 16 Jan 2011 11:21:29 -0000 1.24 *************** *** 485,489 **** foreach(DataRow row in this.downloadedValuesFromSource.Rows) { ! Quotes.UpdateAdjustedClose(this.currentTicker, (DateTime)row[Quotes.Date], (float)row[Quotes.AdjustedClose]); } this.updateCurrentStatusAdjustedClose("Updated"); --- 485,489 ---- foreach(DataRow row in this.downloadedValuesFromSource.Rows) { ! Quotes.UpdateAdjustedClose(this.currentTicker, (DateTime)row[Quotes.Date], (double)row[Quotes.AdjustedClose]); } this.updateCurrentStatusAdjustedClose("Updated"); |
|
From: Marco M. <mi...@us...> - 2011-01-16 11:18:40
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv26178/Tables Modified Files: Quotes.cs Log Message: Fixed bug in method used by the Downloader for updating new adjusted values Index: Quotes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables/Quotes.cs,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** Quotes.cs 4 Aug 2009 21:57:32 -0000 1.37 --- Quotes.cs 16 Jan 2011 11:18:32 -0000 1.38 *************** *** 298,302 **** try { ! float adjustedCloseInDatabase; double absoluteDifference; DataTable tableOfSingleRow = --- 298,302 ---- try { ! double adjustedCloseInDatabase; double absoluteDifference; DataTable tableOfSingleRow = *************** *** 304,308 **** ticker + "' AND quDate=" + SQLBuilder.GetDateConstant(dateToCheck)); ! adjustedCloseInDatabase = (float)(tableOfSingleRow.Rows[0]["quAdjustedClose"]); absoluteDifference = Math.Abs(currentAdjustedValueFromSource - adjustedCloseInDatabase); if(absoluteDifference>ConstantsProvider.MaxDifferenceForAdjustedValues) --- 304,308 ---- ticker + "' AND quDate=" + SQLBuilder.GetDateConstant(dateToCheck)); ! adjustedCloseInDatabase = (double)(tableOfSingleRow.Rows[0]["quAdjustedClose"]); absoluteDifference = Math.Abs(currentAdjustedValueFromSource - adjustedCloseInDatabase); if(absoluteDifference>ConstantsProvider.MaxDifferenceForAdjustedValues) |
|
From: Glauco S. <gla...@us...> - 2011-01-06 19:42:33
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b7_scripts/linearRegression In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv30618/t5_Testing/b7_scripts/linearRegression Modified Files: TestGenomeManagerForLinearRegression.cs Log Message: DecoderForLinearRegressionTestingPositions now has a parametric number of trading positions and a parametric list of signaling portfolios Index: TestGenomeManagerForLinearRegression.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/t5_Testing/b7_scripts/linearRegression/TestGenomeManagerForLinearRegression.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestGenomeManagerForLinearRegression.cs 28 Mar 2010 17:06:10 -0000 1.1 --- TestGenomeManagerForLinearRegression.cs 6 Jan 2011 19:42:26 -0000 1.2 *************** *** 54,58 **** new FakeHistoricalMarketValueProvider() ); DecoderForLinearRegressionTestingPositions decoderForLinearRegressionTestingPositions = ! new DecoderForLinearRegressionTestingPositions( 4 ); LinearRegressionFitnessEvaluator fitnessEvaluator = new LinearRegressionFitnessEvaluator( --- 54,58 ---- new FakeHistoricalMarketValueProvider() ); DecoderForLinearRegressionTestingPositions decoderForLinearRegressionTestingPositions = ! new DecoderForLinearRegressionTestingPositions( 2 , new int[] { 1 , 1 , 1 , 1 } ); LinearRegressionFitnessEvaluator fitnessEvaluator = new LinearRegressionFitnessEvaluator( |
|
From: Glauco S. <gla...@us...> - 2011-01-06 19:42:09
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b7_scripts/linearRegression In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv30555/t5_Testing/b7_scripts/linearRegression Modified Files: TestDecoderForLinearRegressionTestingPositions.cs Log Message: DecoderForLinearRegressionTestingPositions now has a parametric number of trading positions and a parametric list of signaling portfolios Index: TestDecoderForLinearRegressionTestingPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/t5_Testing/b7_scripts/linearRegression/TestDecoderForLinearRegressionTestingPositions.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestDecoderForLinearRegressionTestingPositions.cs 28 Mar 2010 16:56:58 -0000 1.1 --- TestDecoderForLinearRegressionTestingPositions.cs 6 Jan 2011 19:42:01 -0000 1.2 *************** *** 142,146 **** DecoderForLinearRegressionTestingPositions decoderForLinearRegressionTestingPositions = ! new DecoderForLinearRegressionTestingPositions( 3 ); Assert.AreEqual( --- 142,146 ---- DecoderForLinearRegressionTestingPositions decoderForLinearRegressionTestingPositions = ! new DecoderForLinearRegressionTestingPositions( 2 , new int[] { 1 , 1 , 1 } ); Assert.AreEqual( *************** *** 216,220 **** DecoderForLinearRegressionTestingPositions decoderForLinearRegressionTestingPositions = ! new DecoderForLinearRegressionTestingPositions( 3 ); DynamicMock dynamicMockForReturnsManager = new DynamicMock( typeof(IReturnsManager) ); --- 216,220 ---- DecoderForLinearRegressionTestingPositions decoderForLinearRegressionTestingPositions = ! new DecoderForLinearRegressionTestingPositions( 2 , new int[] { 1 , 1 , 1 } ); DynamicMock dynamicMockForReturnsManager = new DynamicMock( typeof(IReturnsManager) ); |
|
From: Glauco S. <gla...@us...> - 2011-01-06 19:40:21
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b7_scripts/linearRegression In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv30237/t5_Testing/b7_scripts/linearRegression Modified Files: TestDecoderFirstTradingTickerInEachSignalingPortfolio.cs Log Message: DecoderFirstTradingTickerInEachSignalingPortfolio is now invoked with two parameters (but the code needs to be fixed, the first parameter is not used at all) Index: TestDecoderFirstTradingTickerInEachSignalingPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/t5_Testing/b7_scripts/linearRegression/TestDecoderFirstTradingTickerInEachSignalingPortfolio.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestDecoderFirstTradingTickerInEachSignalingPortfolio.cs 28 Mar 2010 16:56:37 -0000 1.1 --- TestDecoderFirstTradingTickerInEachSignalingPortfolio.cs 6 Jan 2011 19:40:13 -0000 1.2 *************** *** 146,150 **** DecoderForLinearRegressionTestingPositions decoderForLinearRegressionTestingPositions = ! new DecoderFirstTradingTickerInEachSignalingPortfolio( 3 ); Assert.AreEqual( --- 146,150 ---- DecoderForLinearRegressionTestingPositions decoderForLinearRegressionTestingPositions = ! new DecoderFirstTradingTickerInEachSignalingPortfolio( 2 , 3 ); Assert.AreEqual( *************** *** 221,225 **** DecoderForLinearRegressionTestingPositions decoderForLinearRegressionTestingPositions = ! new DecoderFirstTradingTickerInEachSignalingPortfolio( 3 ); DynamicMock dynamicMockForReturnsManager = new DynamicMock( typeof(IReturnsManager) ); --- 221,225 ---- DecoderForLinearRegressionTestingPositions decoderForLinearRegressionTestingPositions = ! new DecoderFirstTradingTickerInEachSignalingPortfolio( 2 , 3 ); DynamicMock dynamicMockForReturnsManager = new DynamicMock( typeof(IReturnsManager) ); |
|
From: Glauco S. <gla...@us...> - 2011-01-06 19:35:03
|
Update of /cvsroot/quantproject/QuantProject/t5_Testing/b1_ADT/LinearAlgebra In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv28640/t5_Testing/b1_ADT/LinearAlgebra Modified Files: TestLinearSystemSolver.cs Log Message: Copyright notice has been added Index: TestLinearSystemSolver.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/t5_Testing/b1_ADT/LinearAlgebra/TestLinearSystemSolver.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestLinearSystemSolver.cs 28 Mar 2010 16:52:35 -0000 1.1 --- TestLinearSystemSolver.cs 6 Jan 2011 19:34:55 -0000 1.2 *************** *** 1,9 **** /* ! * Created by SharpDevelop. ! * User: Glauco ! * Date: 3/21/2010 ! * Time: 8:10 PM ! * ! * To change this template use Tools | Options | Coding | Edit Standard Headers. */ --- 1,22 ---- /* ! QuantProject - Quantitative Finance Library ! ! TestLinearSystemSolver.cs ! Copyright (C) 2010 ! 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. */ |
|
From: Glauco S. <gla...@us...> - 2011-01-06 19:33:50
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/Strategies In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv28477/b7_Scripts/WalkForwardTesting/LinearRegression/Strategies Modified Files: LinearRegressionStrategy.cs Log Message: more information is now added to each log item Index: LinearRegressionStrategy.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/Strategies/LinearRegressionStrategy.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LinearRegressionStrategy.cs 28 Mar 2010 16:17:02 -0000 1.1 --- LinearRegressionStrategy.cs 6 Jan 2011 19:33:42 -0000 1.2 *************** *** 41,44 **** --- 41,45 ---- public class LinearRegressionStrategy : BasicStrategyForBacktester { + private IReturnIntervalSelectorForSignaling returnIntervalSelectorForSignaling; private IEntryStrategy entryStrategy; private IExitStrategy exitStrategy; *************** *** 49,52 **** --- 50,54 ---- IIntervalsSelector intervalsSelectorForInSample , IIntervalsSelector intervalsSelectorForOutOfSample , + IReturnIntervalSelectorForSignaling returnIntervalSelectorForSignaling , IEligiblesSelector eligiblesSelectorForTradingTickers , // IEligiblesSelector eligiblesSelectorForSignalingTickers , *************** *** 68,71 **** --- 70,74 ---- { this.intervalsSelectorForOutOfSample = intervalsSelectorForOutOfSample; + this.returnIntervalSelectorForSignaling = returnIntervalSelectorForSignaling; this.entryStrategy = entryStrategy; this.exitStrategy = exitStrategy; *************** *** 82,86 **** new LinearRegressionLogItem( this.now() , ! this.bestTestingPositionsInSample ); // this.numDaysForInSampleOptimization , // eligibleTickers.Count ); --- 85,92 ---- new LinearRegressionLogItem( this.now() , ! this.bestTestingPositionsInSample , ! (DateTime)this.inSampleReturnsManager.ReturnIntervals.BordersHistory.GetByIndex( 0 ) , ! this.intervalsSelectorForInSample , ! this.returnIntervalSelectorForSignaling ); // this.numDaysForInSampleOptimization , // eligibleTickers.Count ); *************** *** 104,108 **** bool areToBeOpened = false; if ( this.outOfSampleReturnIntervals.Count >= 1 && ! this.bestTestingPositionsInSample != null ) { // ReturnInterval seconLastInterval = --- 110,114 ---- bool areToBeOpened = false; if ( this.outOfSampleReturnIntervals.Count >= 1 && ! this.bestTestingPositionsInSample != null ) { // ReturnInterval seconLastInterval = |
|
From: Glauco S. <gla...@us...> - 2011-01-06 19:32:07
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/Logging In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv28101/b7_Scripts/WalkForwardTesting/LinearRegression/Logging Modified Files: LinearRegressionLogItem.cs Log Message: more members are now added to analizersForTestingPositions Index: LinearRegressionLogItem.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/Logging/LinearRegressionLogItem.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LinearRegressionLogItem.cs 28 Mar 2010 16:12:57 -0000 1.1 --- LinearRegressionLogItem.cs 6 Jan 2011 19:31:59 -0000 1.2 *************** *** 26,29 **** --- 26,31 ---- using QuantProject.Business.Strategies.Logging; using QuantProject.Business.Strategies.OutOfSample; + using QuantProject.Business.Strategies.ReturnsManagement.Time; + using QuantProject.Business.Strategies.ReturnsManagement.Time.IntervalsSelectors; using QuantProject.Presentation; using QuantProject.Scripts.General.Logging; *************** *** 38,47 **** { // private LinearRegressionTestingPositions[] bestTestingPositionsInSample; public LinearRegressionLogItem( DateTime now , ! TestingPositions[] bestTestingPositionsInSample ) : base( now , bestTestingPositionsInSample ) { // this.bestTestingPositionsInSample = bestTestingPositionsInSample; } --- 40,64 ---- { // private LinearRegressionTestingPositions[] bestTestingPositionsInSample; + DateTime firstDateTimeInSample; + private IIntervalsSelector intervalsSelector; + private IReturnIntervalSelectorForSignaling returnIntervalSelectorForSignaling; public LinearRegressionLogItem( DateTime now , ! TestingPositions[] bestTestingPositionsInSample , ! DateTime firstDateTimeInSample , ! IIntervalsSelector intervalsSelector , ! IReturnIntervalSelectorForSignaling returnIntervalSelectorForSignaling ) : base( now , bestTestingPositionsInSample ) { + this.intervalsSelector = intervalsSelector; + this.returnIntervalSelectorForSignaling = returnIntervalSelectorForSignaling; + this.firstDateTimeInSample = firstDateTimeInSample; + + foreach( AnalyzerForLinearRegressionTestingPositions analizer in + this.analizersForTestingPositions ) + analizer.SetOtherMembers( + firstDateTimeInSample , + intervalsSelector , returnIntervalSelectorForSignaling ); // this.bestTestingPositionsInSample = bestTestingPositionsInSample; } |
|
From: Glauco S. <gla...@us...> - 2011-01-06 19:28:30
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/Logging In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv27008/b7_Scripts/WalkForwardTesting/LinearRegression/Logging Modified Files: AnalyzerForLinearRegressionTestingPositions.cs Log Message: now it has been actually written: analyzes a LinearRegressionTestingPositions that has been logged in sample Index: AnalyzerForLinearRegressionTestingPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/Logging/AnalyzerForLinearRegressionTestingPositions.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AnalyzerForLinearRegressionTestingPositions.cs 28 Mar 2010 16:12:46 -0000 1.1 --- AnalyzerForLinearRegressionTestingPositions.cs 6 Jan 2011 19:28:22 -0000 1.2 *************** *** 22,27 **** --- 22,35 ---- using System; + using System.Drawing; + using System.Windows.Forms; + using QuantProject.ADT.Histories; + using QuantProject.ADT.Statistics; + using QuantProject.Business.DataProviders; using QuantProject.Business.Scripting; + using QuantProject.Business.Strategies.ReturnsManagement.Time; + using QuantProject.Business.Strategies.ReturnsManagement.Time.IntervalsSelectors; + using QuantProject.Presentation; namespace QuantProject.Scripts.WalkForwardTesting.LinearRegression *************** *** 34,49 **** public class AnalyzerForLinearRegressionTestingPositions : IExecutable { ! LinearRegressionTestingPositions linearRegressionTestingPositions; ! DateTime accountTimerDateTimeWhenThisObjectWasLogged; public AnalyzerForLinearRegressionTestingPositions( LinearRegressionTestingPositions linearRegressionTestingPositions , ! // int numberOfInSampleDays , ! DateTime accountTimerDateTimeWhenThisObjectWasLogged ) { this.linearRegressionTestingPositions = linearRegressionTestingPositions; this.accountTimerDateTimeWhenThisObjectWasLogged = accountTimerDateTimeWhenThisObjectWasLogged; } public void Run() { --- 42,227 ---- public class AnalyzerForLinearRegressionTestingPositions : IExecutable { ! private LinearRegressionTestingPositions linearRegressionTestingPositions; ! private DateTime firstDateTimeInSample; ! private IIntervalsSelector intervalsSelector; ! private IReturnIntervalSelectorForSignaling returnIntervalSelectorForSignaling; ! private DateTime accountTimerDateTimeWhenThisObjectWasLogged; + /// <summary> + /// Generation when the TestingPositions object has been created + /// (if genetically optimized) + /// </summary> + public int Generation + { + get + { + return this.linearRegressionTestingPositions.Generation; + } + } + public double FitnessInSample + { + get { return this.linearRegressionTestingPositions.FitnessInSample; } + } + public AnalyzerForLinearRegressionTestingPositions( LinearRegressionTestingPositions linearRegressionTestingPositions , ! DateTime accountTimerDateTimeWhenThisObjectWasLogged ! ) { this.linearRegressionTestingPositions = linearRegressionTestingPositions; + // this.firstDateTimeInSample = firstDateTimeInSample; + // this.intervalsSelector = intervalsSelector; + // this.returnIntervalSelectorForSignaling = returnIntervalSelectorForSignaling; this.accountTimerDateTimeWhenThisObjectWasLogged = accountTimerDateTimeWhenThisObjectWasLogged; } + + public void SetOtherMembers( + DateTime firstDateTimeInSample , + IIntervalsSelector intervalsSelector , + IReturnIntervalSelectorForSignaling returnIntervalSelectorForSignaling ) + { + this.firstDateTimeInSample = firstDateTimeInSample; + this.intervalsSelector = intervalsSelector; + this.returnIntervalSelectorForSignaling = returnIntervalSelectorForSignaling; + } + + #region Run + + #region getReturnIntervals + private ReturnIntervals initializeReturnIntervalsWithTheFirstInterval( + DateTime firstDateTime ) + { + ReturnInterval firstReturnInterval = + this.intervalsSelector.GetFirstInterval( firstDateTime ); + ReturnIntervals returnIntervals = new ReturnIntervals( firstReturnInterval ); + return returnIntervals; + } + private DateTime getFirstDateTime() + { + DateTime firstDateTime = this.accountTimerDateTimeWhenThisObjectWasLogged.AddDays( - 180 ); + return firstDateTime; + } + private DateTime getLastDateTime() + { + DateTime lastDateTime = this.accountTimerDateTimeWhenThisObjectWasLogged; + return lastDateTime; + } + private ReturnInterval getNextInterval( ReturnIntervals returnIntervals ) + { + ReturnInterval returnIntervalForTrading = this.intervalsSelector.GetNextInterval( + returnIntervals ); + // ReturnInterval returnIntervalForSignaling = + // this.returnIntervalSelectorForSignaling.GetReturnIntervalUsedForSignaling( + // returnIntervalForTrading ); + // return returnIntervalForSignaling; + return returnIntervalForTrading; + } + private ReturnIntervals getReturnIntervals( + DateTime firstDateTime , DateTime lastDateTime ) + { + ReturnIntervals returnIntervals = + this.initializeReturnIntervalsWithTheFirstInterval( firstDateTime ); + while ( returnIntervals.LastInterval.End < lastDateTime ) + { + ReturnInterval nextInterval = this.getNextInterval( returnIntervals ); + returnIntervals.Add( nextInterval ); + } + return returnIntervals; + } + private ReturnIntervals getReturnIntervals() + { + // DateTime firstDateTime = this.getFirstDateTime(); + DateTime firstDateTime = this.firstDateTimeInSample; + DateTime lastDateTime = this.getLastDateTime(); + ReturnIntervals returnIntervals = this.getReturnIntervals( + firstDateTime , lastDateTime ); + return returnIntervals; + } + #endregion getReturnIntervals + + private History getVirtualValues( + ReturnIntervals returnIntervals , IVirtualReturnComputer virtualReturnComputer ) + { + History virtualValues = new History(); + int currentIntervalIndex = 0; + double currentValue = 30000; + while ( currentIntervalIndex < returnIntervals.Count ) + { + ReturnInterval currentInterval = returnIntervals[ currentIntervalIndex ]; + if ( !virtualValues.ContainsKey( currentInterval.Begin ) ) + virtualValues.Add( currentInterval.Begin , currentValue ); + try + { + double currentReturn = virtualReturnComputer.ComputeReturn( currentInterval ); + currentValue = currentValue + currentValue * currentReturn; + virtualValues.Add( currentInterval.End , currentValue ); + } + catch( TickerNotExchangedException ) + { + } + currentIntervalIndex++; + } + return virtualValues; + } + + #region getVirtualValues + private void getVirtualValues( + ReturnIntervals returnIntervals , + out History predictedVirtualValues , out History tradingPortfolioVirtualValues ) + { + IHistoricalMarketValueProvider historicalMarketValueProvider = + new HistoricalAdjustedQuoteProvider(); + + ReturnPredictor returnPredictor = new ReturnPredictor( + this.linearRegressionTestingPositions , this.returnIntervalSelectorForSignaling , + historicalMarketValueProvider ); + predictedVirtualValues = this.getVirtualValues( + returnIntervals , returnPredictor ); + + PortfolioReturnComputer tradingPortfolioReturnComputer = + new PortfolioReturnComputer( + this.linearRegressionTestingPositions.TradingPortfolio , + historicalMarketValueProvider ); + tradingPortfolioVirtualValues = this.getVirtualValues( + returnIntervals , tradingPortfolioReturnComputer ); + } + #endregion getVirtualValues + + #region showHistoriesPlots + private HistoriesViewer showHistoriesPlots( + History predictedVirtualValues , History tradingPortfolioVirtualValues ) + { + HistoriesViewer historiesViewer = + new HistoriesViewer( "Linear Regression Log Analyzer" ); + historiesViewer.StartPosition = FormStartPosition.Manual; + historiesViewer.Location = new Point( 200 , 200 ); + historiesViewer.Add( predictedVirtualValues , Color.Red ); + historiesViewer.Add( tradingPortfolioVirtualValues , Color.Green ); + historiesViewer.Show(); + return historiesViewer; + } + #endregion showHistoriesPlots + + #region showCorrelation + private double[] getArrayFromHistory( History history ) + { + double[] arrayValues = new double[ history.Count ]; + for( int i = 0 ; i < arrayValues.Length ; i++ ) + arrayValues[ i ] = (double)history.GetValueList()[ i ]; + return arrayValues; + } + + private void showCorrelation( + History predictedVirtualValues , History tradingPortfolioVirtualValues ) + { + double correlationValue = BasicFunctions.PearsonCorrelationCoefficient( + this.getArrayFromHistory( predictedVirtualValues ) , + this.getArrayFromHistory( tradingPortfolioVirtualValues ) ); + MessageBox.Show( "Correlation value: " + correlationValue ); + } + #endregion showCorrelation + + public void Run() { *************** *** 51,58 **** // coefficients and then show which are those who seem to // be more significant ! System.Windows.Forms.MessageBox.Show( ! "A good analyzer has not yet been thought about, for " + ! "a LinearRegressionTestingPositions" ); } } } --- 229,244 ---- // coefficients and then show which are those who seem to // be more significant ! ReturnIntervals returnIntervals = this.getReturnIntervals(); ! ! History predictedVirtualValues; ! History tradingPortfolioVirtualValues; ! this.getVirtualValues( ! returnIntervals , out predictedVirtualValues , out tradingPortfolioVirtualValues ); ! ! this.showHistoriesPlots( predictedVirtualValues , tradingPortfolioVirtualValues ); ! ! this.showCorrelation( predictedVirtualValues , tradingPortfolioVirtualValues ); } + #endregion Run } } |
|
From: Glauco S. <gla...@us...> - 2011-01-06 19:27:14
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/Genetic In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv26817/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/Genetic Modified Files: GenomeManagerForLinearRegression.cs Log Message: now decoderForLinearRegressionTestingPositions is assigned a parameter value Index: GenomeManagerForLinearRegression.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/Genetic/GenomeManagerForLinearRegression.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GenomeManagerForLinearRegression.cs 28 Mar 2010 16:12:04 -0000 1.1 --- GenomeManagerForLinearRegression.cs 6 Jan 2011 19:27:06 -0000 1.2 *************** *** 97,103 **** seedForRandomGeneratorForSignalingTickers ); this.decoderForLinearRegressionTestingPositions = ! new DecoderForLinearRegressionTestingPositions( ! // decoderForLinearRegressionTestingPositions.NumberOfTickersForTrading , ! decoderForLinearRegressionTestingPositions.NumberOfSignalingPortfolios ); this.genomeSize = decoderForLinearRegressionTestingPositions.NumberOfTickersForTrading + --- 97,104 ---- seedForRandomGeneratorForSignalingTickers ); this.decoderForLinearRegressionTestingPositions = ! decoderForLinearRegressionTestingPositions; ! // new DecoderForLinearRegressionTestingPositions( ! //// decoderForLinearRegressionTestingPositions.NumberOfTickersForTrading , ! // decoderForLinearRegressionTestingPositions.NumberOfSignalingPortfolios ); this.genomeSize = decoderForLinearRegressionTestingPositions.NumberOfTickersForTrading + |
|
From: Glauco S. <gla...@us...> - 2011-01-06 19:24:26
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/FitnessEvaluation In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv25966/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/FitnessEvaluation Modified Files: LinearRegressionFitnessEvaluator.cs Log Message: - unused code have been removed - now the interface QuantProject.ADT.Econometrics.ILinearRegression is reference, instead of an implementing class Index: LinearRegressionFitnessEvaluator.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/FitnessEvaluation/LinearRegressionFitnessEvaluator.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LinearRegressionFitnessEvaluator.cs 28 Mar 2010 16:08:00 -0000 1.1 --- LinearRegressionFitnessEvaluator.cs 6 Jan 2011 19:24:19 -0000 1.2 *************** *** 92,96 **** } ! public QuantProject.ADT.Econometrics.LinearRegression SetUpAndRunLinearRegression( LinearRegressionTestingPositions testingPositions ) { --- 92,96 ---- } ! public QuantProject.ADT.Econometrics.ILinearRegression SetUpAndRunLinearRegression( LinearRegressionTestingPositions testingPositions ) { *************** *** 100,103 **** --- 100,105 ---- this.returnsManagerForTradingTickers , this.returnsManagerForSignalingTickers ); + // QuantProject.ADT.Econometrics.LinearRegression linearRegression = + // new QuantProject.ADT.Econometrics.LinearRegressionWithoutCovarianceMatrix(); QuantProject.ADT.Econometrics.LinearRegression linearRegression = new QuantProject.ADT.Econometrics.LinearRegression(); *************** *** 128,156 **** #region getFitnessValue - private double getFitnessValue( - WeightedPositions tradingPortfolio , - WeightedPositions[] signalingPortfolios ) - { - ILinearRegressionValues linearRegressionValues = - this.linearRegressionSetupManger.SetUpTheLinearRegressionValues( - tradingPortfolio , signalingPortfolios , - this.returnsManagerForTradingTickers , - this.returnsManagerForSignalingTickers ); - // this.getFitnessValue_checkWeightedPositions( weightedPositions ); - // QuantProject.ADT.Econometrics.LinearRegression linearRegression = - // this.setupAndRunTheLinearRegression( - // tradingPortfolio , signalingPortfolios , returnsManager ); - QuantProject.ADT.Econometrics.LinearRegression linearRegression = - new QuantProject.ADT.Econometrics.LinearRegression(); - linearRegression.RunRegression( - linearRegressionValues.Regressand , - linearRegressionValues.Regressors ); - // linearRegressionValues.RegressorWeights ); - double fitnessValue = linearRegression.CenteredRSquare; - return fitnessValue; - } private double getFitnessValue( LinearRegressionTestingPositions testingPositions ) { ! QuantProject.ADT.Econometrics.LinearRegression linearRegression = this.SetUpAndRunLinearRegression( testingPositions ); double fitnessValue = linearRegression.CenteredRSquare; --- 130,136 ---- #region getFitnessValue private double getFitnessValue( LinearRegressionTestingPositions testingPositions ) { ! QuantProject.ADT.Econometrics.ILinearRegression linearRegression = this.SetUpAndRunLinearRegression( testingPositions ); double fitnessValue = linearRegression.CenteredRSquare; *************** *** 177,184 **** fitnessValue = this.getFitnessValue( (LinearRegressionTestingPositions)meaning ); ! // this.hasReturnsManagerForTradingTickersBeenSetSinceLastGetFitnessValueRequest = ! // false; ! // this.hasReturnsManagerForSignalingTickersBeenSetSinceLastGetFitnessValueRequest = ! // false; return fitnessValue; } --- 157,164 ---- fitnessValue = this.getFitnessValue( (LinearRegressionTestingPositions)meaning ); ! if ( fitnessValue < -0.03 && fitnessValue > -2 ) ! { ! string forBreakpoint; // for breakpoint ! } return fitnessValue; } |
|
From: Glauco S. <gla...@us...> - 2011-01-06 18:56:34
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/Decoding In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv19385/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/Decoding Modified Files: DecoderForLinearRegressionTestingPositions.cs Log Message: The behavior of the decoder has been changed. Now the genome is decoded as follows: a given number of tickers is used to decode a trading portfolio. Then, a given number of signaling portfolios are created, each with a given number of contained signaling tickers. Index: DecoderForLinearRegressionTestingPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/Decoding/DecoderForLinearRegressionTestingPositions.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DecoderForLinearRegressionTestingPositions.cs 28 Mar 2010 16:02:47 -0000 1.1 --- DecoderForLinearRegressionTestingPositions.cs 6 Jan 2011 18:56:26 -0000 1.2 *************** *** 34,39 **** /// <summary> /// Simple decoder for the Linear Regression strategy. ! /// The genome is decoded as follows: the first two tickers are used to decode /// a trading portfolio. /// For each of the other tickers is created a portfolio with that single ticker and /// such portfolio is used as a signaling portfolio. --- 34,41 ---- /// <summary> /// Simple decoder for the Linear Regression strategy. ! /// The genome is decoded as follows: a given number of tickers is used to decode /// a trading portfolio. + /// Then, a given number of signaling portfolios are created, each with its number + /// of contained tickers. /// For each of the other tickers is created a portfolio with that single ticker and /// such portfolio is used as a signaling portfolio. *************** *** 45,78 **** public class DecoderForLinearRegressionTestingPositions // : IDecoderForTestingPositions { ! // private int numberOfTickersForTrading; ! // public int NumberOfTickersForTrading { ! // get { return this.numberOfTickersForTrading; } ! get { return 2; } } // - private int numberOfSignalingPortfolios; // public int NumberOfSignalingPortfolios { ! get { return this.numberOfSignalingPortfolios; } } private BasicDecoderForTestingPositions basicDecoderForTestingPositions; ! public DecoderForLinearRegressionTestingPositions( int numberOfSignalingPortfolios ) ! // int numberOfTickersForTrading , int numberOfTickersForSignaling ) { ! // this.numberOfTickersForTrading = numberOfTickersForTrading; ! this.numberOfSignalingPortfolios = numberOfSignalingPortfolios; this.basicDecoderForTestingPositions = new BasicDecoderForTestingPositions(); } #region Decode ! private void decode_checkParameters( int[] genome ) { ! int numberOfExpectedGenes = this.numberOfSignalingPortfolios + 2; ! if ( genome.Length != numberOfExpectedGenes ) throw new Exception( ! "The given genom contains " + genome.Length + " genes, but " + ! numberOfExpectedGenes + " where expected!" ); } private int[] getSubGenome( int[] genome , int startingPosition , int length ) --- 47,92 ---- public class DecoderForLinearRegressionTestingPositions // : IDecoderForTestingPositions { ! private int numberOfTickersForTrading; ! ! private int[] numberOfTickersInEachSignalingPortfolio; ! public int NumberOfTickersForTrading { ! get { return this.numberOfTickersForTrading; } } // // public int NumberOfSignalingPortfolios { ! get { return this.numberOfTickersInEachSignalingPortfolio.Length; } } + private BasicDecoderForTestingPositions basicDecoderForTestingPositions; + protected int expectedNumberOfGeneValues; ! public DecoderForLinearRegressionTestingPositions( ! int numberOfTickersForTrading , int[] numberOfTickersInEachSignalingPortfolio ) { ! this.numberOfTickersForTrading = numberOfTickersForTrading; ! this.numberOfTickersInEachSignalingPortfolio = ! numberOfTickersInEachSignalingPortfolio; ! this.basicDecoderForTestingPositions = new BasicDecoderForTestingPositions(); + this.setExpectedNumberOfGeneValues(); + } + + private void setExpectedNumberOfGeneValues() + { + this.expectedNumberOfGeneValues = this.numberOfTickersForTrading; + for( int i = 0 ; i < this.NumberOfSignalingPortfolios ; i++ ) + this.expectedNumberOfGeneValues += + this.numberOfTickersInEachSignalingPortfolio[ i ]; } #region Decode ! virtual protected void decode_checkParameters( int[] genome ) { ! if ( genome.Length != this.expectedNumberOfGeneValues ) throw new Exception( ! "The given genome contains " + genome.Length + " genes, but " + ! this.expectedNumberOfGeneValues + " where expected!" ); } private int[] getSubGenome( int[] genome , int startingPosition , int length ) *************** *** 90,94 **** int[] encodedForTradingTickers = // this.getSubGenome( encoded , 0 , this.numberOfTickersForTrading ); ! this.getSubGenome( encoded , 0 , 2 ); WeightedPositions weightedPositionsForTrading = this.basicDecoderForTestingPositions.Decode( --- 104,108 ---- int[] encodedForTradingTickers = // this.getSubGenome( encoded , 0 , this.numberOfTickersForTrading ); ! this.getSubGenome( encoded , 0 , this.numberOfTickersForTrading ); WeightedPositions weightedPositionsForTrading = this.basicDecoderForTestingPositions.Decode( *************** *** 105,109 **** this.getSubGenome( // encoded , this.numberOfTickersForTrading , this.numberOfTickersForSignaling ); ! encoded , 2 , encoded.Length - 2 ); WeightedPositions weightedPositionsForSignaling = this.basicDecoderForTestingPositions.Decode( --- 119,124 ---- this.getSubGenome( // encoded , this.numberOfTickersForTrading , this.numberOfTickersForSignaling ); ! encoded , this.numberOfTickersForTrading , ! encoded.Length - this.numberOfTickersForTrading ); WeightedPositions weightedPositionsForSignaling = this.basicDecoderForTestingPositions.Decode( *************** *** 130,133 **** --- 145,158 ---- #region getTradingPortfolio + + #region getSignedTickersForTradingPortfolio + private SignedTicker[] getSignedTickersArray( + WeightedPositions weightedPositionsForTrading ) + { + SignedTicker[] signedTickersArray = new SignedTicker[ weightedPositionsForTrading.Count ]; + for( int i = 0 ; i < weightedPositionsForTrading.Count ; i++ ) + signedTickersArray[ i ] = weightedPositionsForTrading.SignedTickers[ i ]; + return signedTickersArray; + } protected virtual SignedTickers getSignedTickersForTradingPortfolio( WeightedPositions weightedPositionsForTrading , *************** *** 135,143 **** { SignedTickers signedTickersForTradingPortfolio = new SignedTickers( ! new SignedTicker[] { ! weightedPositionsForTrading.SignedTickers[ 0 ] , ! weightedPositionsForTrading.SignedTickers[ 1 ] } ); return signedTickersForTradingPortfolio; } private WeightedPositions getTradingPortfolio( WeightedPositions weightedPositionsForTrading , --- 160,171 ---- { SignedTickers signedTickersForTradingPortfolio = new SignedTickers( ! this.getSignedTickersArray( weightedPositionsForTrading ) ); ! // new SignedTicker[] { ! // weightedPositionsForTrading.SignedTickers[ 0 ] , ! // weightedPositionsForTrading.SignedTickers[ 1 ] } ); return signedTickersForTradingPortfolio; } + #endregion getSignedTickersForTradingPortfolio + private WeightedPositions getTradingPortfolio( WeightedPositions weightedPositionsForTrading , *************** *** 224,229 **** /// <summary> ! /// The genome is decoded as follows: the first two tickers are used to decode /// a trading portfolio. /// For each of the other tickers is created a portfolio with that single ticker and /// such portfolio is used as a signaling portfolio. --- 252,260 ---- /// <summary> ! /// Simple decoder for the Linear Regression strategy. ! /// The genome is decoded as follows: a given number of tickers is used to decode /// a trading portfolio. + /// Then, a given number of signaling portfolios are created, each with its number + /// of contained tickers. /// For each of the other tickers is created a portfolio with that single ticker and /// such portfolio is used as a signaling portfolio. |
|
From: Glauco S. <gla...@us...> - 2011-01-06 18:52:38
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/Decoding In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv18215/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/Decoding Modified Files: DecoderFirstTradingTickerInEachSignalingPortfolio.cs Log Message: useless comments have been removed Index: DecoderFirstTradingTickerInEachSignalingPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/InSampleChoosers/Decoding/DecoderFirstTradingTickerInEachSignalingPortfolio.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DecoderFirstTradingTickerInEachSignalingPortfolio.cs 28 Mar 2010 15:57:29 -0000 1.1 --- DecoderFirstTradingTickerInEachSignalingPortfolio.cs 6 Jan 2011 18:52:30 -0000 1.2 *************** *** 37,41 **** /// of n-1 WeightedPositions: the i_th WeightedPositions contains the balanced portfolio /// with two positions: one for the ticker of the first gene and one for the ticker ! /// of the i+1_th gene; the first two ticker are decoded using the eligible tickers /// for trading, while the other tickers are decoded using the eligible tickers /// for signaling --- 37,41 ---- /// of n-1 WeightedPositions: the i_th WeightedPositions contains the balanced portfolio /// with two positions: one for the ticker of the first gene and one for the ticker ! /// of the i+1_th gene; the first two tickers are decoded using the eligible tickers /// for trading, while the other tickers are decoded using the eligible tickers /// for signaling *************** *** 45,160 **** DecoderForLinearRegressionTestingPositions { ! //// private int numberOfTickersForTrading; ! //// ! // public int NumberOfTickersForTrading { ! //// get { return this.numberOfTickersForTrading; } ! // get { return 2; } ! // } ! //// ! // private int numberOfTickersForSignaling; ! //// ! // public int NumberOfTickersForSignaling { ! // get { return this.numberOfTickersForSignaling; } ! // } ! // private BasicDecoderForTestingPositions basicDecoderForTestingPositions; ! // ! public DecoderFirstTradingTickerInEachSignalingPortfolio( int numberOfTickersForSignaling ) : ! base( numberOfTickersForSignaling ) { ! } ! // int numberOfTickersForTrading , int numberOfTickersForSignaling ) ! // { ! // this.numberOfTickersForTrading = numberOfTickersForTrading; ! // this.numberOfTickersForSignaling = numberOfTickersForSignaling; ! // this.basicDecoderForTestingPositions = new BasicDecoderForTestingPositions(); ! // } ! // ! // #region Decode ! // private void decode_checkParameters( int[] genome ) ! // { ! // int numberOfExpectedGenes = this.numberOfTickersForSignaling + 2; ! // if ( genome.Length != numberOfExpectedGenes ) ! // throw new Exception( ! // "The given genom contains " + genome.Length + " genes, but " + ! // numberOfExpectedGenes + " where expected!" ); ! // } ! // private int[] getSubGenome( int[] genome , int startingPosition , int length ) ! // { ! // int[] subGenome = new int[ length ]; ! // for( int i = startingPosition ; i < startingPosition + length ; i++ ) ! // subGenome[ i - startingPosition ] = genome[ i ]; ! // return subGenome; ! // } ! // private WeightedPositions decodeWeightedPositionsForTrading( ! // int[] encoded , ! // EligibleTickers eligibleTickersForTrading , ! // IReturnsManager returnsManager ) ! // { ! // int[] encodedForTradingTickers = ! //// this.getSubGenome( encoded , 0 , this.numberOfTickersForTrading ); ! // this.getSubGenome( encoded , 0 , 2 ); ! // WeightedPositions weightedPositionsForTrading = ! // this.basicDecoderForTestingPositions.Decode( ! // encodedForTradingTickers , ! // eligibleTickersForTrading , returnsManager ).WeightedPositions; ! // return weightedPositionsForTrading; ! // } ! // private WeightedPositions decodeWeightedPositionsForSignaling( ! // int[] encoded , ! // EligibleTickers eligibleTickersForSignaling , ! // IReturnsManager returnsManager ) ! // { ! // int[] encodedForSignalingTickers = ! // this.getSubGenome( ! //// encoded , this.numberOfTickersForTrading , this.numberOfTickersForSignaling ); ! // encoded , 2 , encoded.Length - 2 ); ! // WeightedPositions weightedPositionsForSignaling = ! // this.basicDecoderForTestingPositions.Decode( ! // encodedForSignalingTickers , ! // eligibleTickersForSignaling , returnsManager ).WeightedPositions; ! // return weightedPositionsForSignaling; ! // } ! // ! // #region getTestingPositions ! // protected virtual WeightedPositions getBalancedPortfolio( ! // SignedTickers signedTickers , ! // IReturnsManager returnsManager ) ! // { ! // WeightedPositions balancedPortfolio = null; ! // if ( !CollectionManager.ContainsDuplicates( signedTickers.Tickers ) ) ! // { ! // double[] balancedWeights = WeightedPositions.GetBalancedWeights( ! // signedTickers , returnsManager ); ! // balancedPortfolio = ! // new WeightedPositions( balancedWeights , signedTickers.Tickers ); ! // } ! // return balancedPortfolio; ! // } ! // ! // #region getTradingPortfolio ! // protected virtual SignedTickers getSignedTickersForTradingPortfolio( ! // WeightedPositions weightedPositionsForTrading , ! // IReturnsManager returnsManager ) ! // { ! // SignedTickers signedTickersForTradingPortfolio = new SignedTickers( ! // new SignedTicker[] { ! // weightedPositionsForTrading.SignedTickers[ 0 ] , ! // weightedPositionsForTrading.SignedTickers[ 1 ] } ); ! // return signedTickersForTradingPortfolio; ! // } ! // private WeightedPositions getTradingPortfolio( ! // WeightedPositions weightedPositionsForTrading , ! // IReturnsManager returnsManager ) ! // { ! // SignedTickers signedTickers = this.getSignedTickersForTradingPortfolio( ! // weightedPositionsForTrading , returnsManager ); ! // WeightedPositions tradingPortfolio = this.getBalancedPortfolio( ! // signedTickers , returnsManager ); ! // return tradingPortfolio; ! // } ! // #endregion getTradingPortfolio ! // ! // #region getSignalingPortfolios protected override SignedTickers getSignedTickersForSignalingPortfolio( int portfolioIndex , --- 45,74 ---- DecoderForLinearRegressionTestingPositions { ! ! public DecoderFirstTradingTickerInEachSignalingPortfolio( ! int numberOfTickersForTrading , int numberOfSignalingPortfolios ) : ! base( 2 , getNumberOfTickersForTrading( numberOfSignalingPortfolios ) ) { ! this.expectedNumberOfGeneValues = 2 + numberOfSignalingPortfolios; } ! ! private static int[] getNumberOfTickersForTrading( int numberOfSignalingPortfolios ) ! { ! int[] numberOfTickersInEachSignalingPortfolio = ! new int[ numberOfSignalingPortfolios ]; ! for ( int i = 0 ; i < numberOfSignalingPortfolios ; i++ ) ! numberOfTickersInEachSignalingPortfolio[ i ] = 2; ! return numberOfTickersInEachSignalingPortfolio; ! } ! ! protected override void decode_checkParameters( int[] genome ) ! { ! if ( genome.Length != this.expectedNumberOfGeneValues ) ! throw new Exception( ! "The given genome contains " + genome.Length + " genes, but " + ! this.expectedNumberOfGeneValues + " where expected!" ); ! } ! ! protected override SignedTickers getSignedTickersForSignalingPortfolio( int portfolioIndex , *************** *** 169,253 **** return signedTickersForSignalingPortfolio; } ! // private WeightedPositions getSignalingPortfolio( ! // int portfolioIndex , ! // WeightedPositions weightedPositionsForTrading , ! // WeightedPositions weightedPositionsForSignaling , ! // IReturnsManager returnsManager ) ! // { ! // SignedTickers signedTickers = this.getSignedTickersForSignalingPortfolio( ! // portfolioIndex , weightedPositionsForTrading , weightedPositionsForSignaling , ! // returnsManager ); ! // WeightedPositions signalingPortfolio = this.getBalancedPortfolio( ! // signedTickers , returnsManager ); ! // return signalingPortfolio; ! // } ! // private WeightedPositions[] getSignalingPortfolios( ! // WeightedPositions weightedPositionsForTrading , ! // WeightedPositions weightedPositionsForSignaling , ! // IReturnsManager returnsManager ) ! // { ! // bool containsSignalingPortfolioWithDuplicateTickers = false; ! // WeightedPositions[] signalingPortfolios = new WeightedPositions[ ! // weightedPositionsForSignaling.Count ]; ! // for ( int j=0 ; j < weightedPositionsForSignaling.Count ; j++ ) ! // { ! // signalingPortfolios[ j ] = this.getSignalingPortfolio( ! // j , weightedPositionsForTrading , weightedPositionsForSignaling , ! // returnsManager ); ! // if ( signalingPortfolios[ j ] == null ) ! // containsSignalingPortfolioWithDuplicateTickers = true; ! // } ! // if ( containsSignalingPortfolioWithDuplicateTickers ) ! // signalingPortfolios = null; ! // return signalingPortfolios; ! // } ! // #endregion getSignalingPortfolios ! // ! // ! // ! // private TestingPositions getTestingPositions( ! // WeightedPositions weightedPositionsForTrading , ! // WeightedPositions weightedPositionsForSignaling , ! // IReturnsManager returnsManagerForTradingTickers , ! // IReturnsManager returnsManagerForSignalingTickers ) ! // { ! // TestingPositions testingPositions = new TestingPositionsForUndecodableEncoded(); ! // WeightedPositions tradingPortfolio = this.getTradingPortfolio( ! // weightedPositionsForTrading , returnsManagerForTradingTickers ); ! // WeightedPositions[] signalingPortfolios = this.getSignalingPortfolios( ! // weightedPositionsForTrading , weightedPositionsForSignaling , ! // returnsManagerForSignalingTickers ); ! // if ( tradingPortfolio != null && signalingPortfolios != null ) ! // // all portfolios are valid, because none of them contained ! // // duplicated tickers ! // testingPositions = new LinearRegressionTestingPositions( ! // signalingPortfolios , tradingPortfolio ); ! // return testingPositions; ! // } ! // #endregion getTestingPositions ! // ! // public TestingPositions Decode( ! // int[] encoded , ! // EligibleTickers eligibleTickersForTrading , ! // EligibleTickers eligibleTickersForSignaling , ! // IReturnsManager returnsManagerForTradingTickers , ! // IReturnsManager returnsManagerForSignalingTickers ) ! // { ! // this.decode_checkParameters( encoded ); ! // WeightedPositions weightedPositionsForTrading = ! // this.decodeWeightedPositionsForTrading( ! // encoded , eligibleTickersForTrading , returnsManagerForTradingTickers ); ! // WeightedPositions weightedPositionsForSignaling = ! // this.decodeWeightedPositionsForSignaling( ! // encoded , eligibleTickersForSignaling , returnsManagerForSignalingTickers ); ! // TestingPositions meaning = new TestingPositionsForUndecodableEncoded(); ! // if ( weightedPositionsForTrading != null && weightedPositionsForSignaling != null ) ! // // there were not duplicated tickers in the encoded ! // meaning = this.getTestingPositions( ! // weightedPositionsForTrading , weightedPositionsForSignaling , ! // returnsManagerForTradingTickers , returnsManagerForSignalingTickers ); ! // return meaning; ! // } ! // #endregion Decode } } --- 83,90 ---- return signedTickersForSignalingPortfolio; } ! ! ! ! } } |
|
From: Glauco S. <gla...@us...> - 2011-01-06 18:44:17
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv15939/b7_Scripts/WalkForwardTesting/LinearRegression Modified Files: LinearRegressionMain.cs Log Message: minor changes to the script parameters Index: LinearRegressionMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearRegression/LinearRegressionMain.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LinearRegressionMain.cs 28 Mar 2010 15:48:08 -0000 1.1 --- LinearRegressionMain.cs 6 Jan 2011 18:44:08 -0000 1.2 *************** *** 97,109 **** ITickerSelectorByGroup tickerSelectorByGroup = new TickerSelectorByGroup(); // double minPercentageOfAvailableValues = 0.8; ! double minPercentageOfAvailableValues = 0.9; double minPriceForTradingTicker = 1; double maxPriceForTradingTicker = 9000; int maxNumberOfEligiblesForTrading = 150; ! // uncomment the followings line for a faster script ! // groupIdForTradingTickers = "fastTest"; ! // groupIdForAdditionalSignalingTickers = "fastTest"; ! // maxNumberOfEligiblesForTrading = 8; IEligiblesSelector eligiblesSelector = --- 97,109 ---- ITickerSelectorByGroup tickerSelectorByGroup = new TickerSelectorByGroup(); // double minPercentageOfAvailableValues = 0.8; ! double minPercentageOfAvailableValues = 1; double minPriceForTradingTicker = 1; double maxPriceForTradingTicker = 9000; int maxNumberOfEligiblesForTrading = 150; ! // uncomment the followings lines for a faster script ! groupIdForTradingTickers = "fastTest"; ! groupIdForAdditionalSignalingTickers = "fastTest"; ! maxNumberOfEligiblesForTrading = 8; IEligiblesSelector eligiblesSelector = *************** *** 133,145 **** // uncomment the following line for a faster script // numberOfBestTestingPositionsToBeReturned = 20; ! // numberOfBestTestingPositionsToBeReturned = 5; ! // int numberOfTickersForTrading = 2; ! int numberOfSignalingPortfolios = 4; DecoderForLinearRegressionTestingPositions decoderForWeightedPositions = new DecoderForLinearRegressionTestingPositions( ! numberOfSignalingPortfolios ); ! // numberOfTickersForTrading , numberOfTickersForSignaling ); // double maxCorrelationAllowed = 0.96; copypasted --- 133,145 ---- // uncomment the following line for a faster script // numberOfBestTestingPositionsToBeReturned = 20; ! numberOfBestTestingPositionsToBeReturned = 3; ! int numberOfTickersForTrading = 1; ! int[] numberOfTickersInEachSignalingPortfolio = ! new int[] { 1 , 1 , 1 }; DecoderForLinearRegressionTestingPositions decoderForWeightedPositions = new DecoderForLinearRegressionTestingPositions( ! numberOfTickersForTrading , numberOfTickersInEachSignalingPortfolio ); // double maxCorrelationAllowed = 0.96; copypasted *************** *** 164,176 **** // parameters for the genetic optimizer ! double crossoverRate = 0.85; double mutationRate = 0.02; ! double elitismRate = 0.001; int populationSizeForGeneticOptimizer = 60000; int generationNumberForGeneticOptimizer = 15; // uncomment the followings line for a faster script ! // populationSizeForGeneticOptimizer = 300; ! // generationNumberForGeneticOptimizer = 4; int seedForRandomGeneratorForTheGeneticOptimizer = --- 164,176 ---- // parameters for the genetic optimizer ! double crossoverRate = 0.5; double mutationRate = 0.02; ! double elitismRate = 0.00001; int populationSizeForGeneticOptimizer = 60000; int generationNumberForGeneticOptimizer = 15; // uncomment the followings line for a faster script ! populationSizeForGeneticOptimizer = 300; ! generationNumberForGeneticOptimizer = 4; int seedForRandomGeneratorForTheGeneticOptimizer = *************** *** 210,217 **** { int inSampleDays = 180; ! inSampleDays = 360; // uncomment the following line for a faster script ! // inSampleDays = 5; ! // inSampleDays = 60; // IIntervalsSelector intervalsSelectorForOutOfSample = --- 210,217 ---- { int inSampleDays = 180; ! // inSampleDays = 360; // uncomment the following line for a faster script ! // inSampleDays = 20; ! inSampleDays = 60; // IIntervalsSelector intervalsSelectorForOutOfSample = *************** *** 237,241 **** maxTimeSpanToLookAhead ); ! double minForecastedReturn = 0.01F; IEntryStrategy longAndShortBasedOnAverageExpectedReturn = new EntryStrategyBasedOnForecastedReturn( --- 237,241 ---- maxTimeSpanToLookAhead ); ! double minForecastedReturn = 0.002F; IEntryStrategy longAndShortBasedOnAverageExpectedReturn = new EntryStrategyBasedOnForecastedReturn( *************** *** 250,253 **** --- 250,254 ---- 7 , inSampleDays , intervalsSelectorForInSample , intervalsSelectorForOutOfSample , + this.returnIntervalSelectorForSignaling , eligiblesSelector , // eligible selector for trading tickers // this.eligiblesSelectorForSignalingTickers , *************** *** 287,292 **** // uncomment the following two lines for a faster script ! // firstDateTime = new DateTime( 2006 , 1 , 2 ); ! // lastDateTime = new DateTime( 2006 , 1 , 10 ); double maxRunningHours = 12; --- 288,295 ---- // uncomment the following two lines for a faster script ! firstDateTime = new DateTime( 2006 , 2 , 26 ); ! lastDateTime = new DateTime( 2006 , 4 , 5 ); ! // firstDateTime = new DateTime( 2005 , 2 , 26 ); ! // lastDateTime = new DateTime( 2006 , 12 , 5 ); double maxRunningHours = 12; |
|
From: Glauco S. <gla...@us...> - 2011-01-06 18:43:10
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/General/Logging In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv15610/b7_Scripts/General/Logging Modified Files: AnalyzableLogItem.cs Log Message: analizersForTestingPositions was private, is protected now Index: AnalyzableLogItem.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/General/Logging/AnalyzableLogItem.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AnalyzableLogItem.cs 28 Mar 2010 15:47:36 -0000 1.1 --- AnalyzableLogItem.cs 6 Jan 2011 18:43:02 -0000 1.2 *************** *** 38,42 **** public abstract class AnalyzableLogItem : LogItem { ! private List<IExecutable> analizersForTestingPositions; protected TestingPositions[] bestTestingPositionsInSample; --- 38,42 ---- public abstract class AnalyzableLogItem : LogItem { ! protected List<IExecutable> analizersForTestingPositions; protected TestingPositions[] bestTestingPositionsInSample; |