quantproject-developers Mailing List for QuantProject (Page 72)
Brought to you by:
glauco_1
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(7) |
Nov
(103) |
Dec
(67) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(52) |
Feb
(9) |
Mar
(69) |
Apr
(53) |
May
(80) |
Jun
(23) |
Jul
(24) |
Aug
(112) |
Sep
(9) |
Oct
|
Nov
(58) |
Dec
(93) |
| 2005 |
Jan
(90) |
Feb
(93) |
Mar
(61) |
Apr
(56) |
May
(37) |
Jun
(61) |
Jul
(55) |
Aug
(68) |
Sep
(25) |
Oct
(46) |
Nov
(41) |
Dec
(37) |
| 2006 |
Jan
(33) |
Feb
(7) |
Mar
(19) |
Apr
(27) |
May
(73) |
Jun
(49) |
Jul
(83) |
Aug
(66) |
Sep
(45) |
Oct
(16) |
Nov
(15) |
Dec
(7) |
| 2007 |
Jan
(14) |
Feb
(33) |
Mar
|
Apr
(21) |
May
|
Jun
(34) |
Jul
(18) |
Aug
(100) |
Sep
(39) |
Oct
(55) |
Nov
(12) |
Dec
(2) |
| 2008 |
Jan
(120) |
Feb
(133) |
Mar
(129) |
Apr
(104) |
May
(42) |
Jun
(2) |
Jul
(52) |
Aug
(99) |
Sep
(134) |
Oct
|
Nov
(137) |
Dec
(48) |
| 2009 |
Jan
(48) |
Feb
(55) |
Mar
(61) |
Apr
(3) |
May
(2) |
Jun
(1) |
Jul
|
Aug
(51) |
Sep
|
Oct
(7) |
Nov
|
Dec
|
| 2010 |
Jan
(7) |
Feb
(1) |
Mar
(145) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(8) |
Dec
|
| 2011 |
Jan
(78) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(88) |
Sep
(6) |
Oct
(1) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
(1) |
Mar
|
Apr
(6) |
May
(5) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2013 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Glauco S. <gla...@us...> - 2007-08-07 16:48:19
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv21337/b4_Business/a2_Strategies Modified Files: SignedTicker.cs Log Message: Dramatically changed: moved from a static string based approach to a OO oriented instance based scenario. Several static methods have been left for legacy support, but classes using those methods should be patched to use the OO based approach. Index: SignedTicker.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/SignedTicker.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SignedTicker.cs 24 Jun 2007 21:29:00 -0000 1.8 --- SignedTicker.cs 7 Aug 2007 16:48:12 -0000 1.9 *************** *** 52,55 **** --- 52,100 ---- get { return this.positionType; } } + public double Multiplier + { + get + { + double multiplier = 1; + if ( this.IsShort ) + multiplier = -1; + return multiplier; + } + } + public bool IsShort + { + get + { + bool isShort = ( this.positionType == PositionType.Short ); + return isShort; + } + } + public bool IsLong + { + get + { + return !this.IsShort; + } + } + public SignedTicker OppositeSignedTicker + { + get + { + SignedTicker oppositeSignedTicker = + new SignedTicker( this.Ticker , + this.getOppositePositionType( this.PositionType ) ); + return oppositeSignedTicker; + } + } + private PositionType getOppositePositionType( PositionType positionType ) + { + PositionType oppositePositionType; + if ( this.IsLong ) + oppositePositionType = PositionType.Short; + else + // this.IsShort + oppositePositionType = PositionType.Long; + return oppositePositionType; + } public SignedTicker( string ticker , PositionType positionType ) { *************** *** 57,60 **** --- 102,158 ---- this.positionType = positionType; } + public SignedTicker( string signedTicker ) + { + this.signedTicker_checkParams( signedTicker ); + this.ticker = this.getTicker( signedTicker ); + this.positionType = this.getPositionType( signedTicker ); + } + private bool isValidSignedTicker( string signedTicker ) + { + bool isActuallyValidSignedTicker = false; + string firstCharacter = signedTicker.Substring( 0 , 1 ); + if ( ( firstCharacter.CompareTo( "A" ) != - 1 ) && + ( ( firstCharacter.CompareTo( "Z" ) != 1 ) ) ) + // the first signedTickers' character is an upcase letter + isActuallyValidSignedTicker = true; + if ( ( firstCharacter == "^" ) ) + isActuallyValidSignedTicker = true; + if ( ( firstCharacter == "-" ) ) + isActuallyValidSignedTicker = true; + return isActuallyValidSignedTicker; + } + private void signedTicker_checkParams( string signedTicker ) + { + if ( !this.isValidSignedTicker( signedTicker ) ) + throw new Exception( "signedTickers is not a valid string to " + + "identify and construct a new SignedTicker object!" ); + } + private bool isStringForLongSignedTicker( string signedTicker ) + { + return !(signedTicker.IndexOf( "-" ) == 0 ); + } + private string getTicker( string signedTicker ) + { + string ticker; + if ( this.isStringForLongSignedTicker( signedTicker ) ) + ticker = signedTicker; + else + // signedTicker is a string for a short SignedTicker and + // signedTicker begins with a '-' sign + ticker = signedTicker.Substring( 1 ); + return ticker; + } + private PositionType getPositionType( string signedTicker ) + { + PositionType positionType; + if ( this.isStringForLongSignedTicker( signedTicker ) ) + positionType = PositionType.Long; + else + // signedTicker is a string for a short SignedTicker and + // signedTicker begins with a '-' sign + positionType = PositionType.Short; + return positionType; + } + public static string GetSignedTicker( Position position ) { *************** *** 71,102 **** return ticker; } ! public static bool IsShort( string signedTicker ) ! { ! return ( signedTicker.StartsWith( "-" ) ); ! } ! public static bool IsLong( string signedTicker ) ! { ! return ( !SignedTicker.IsShort( signedTicker ) ); ! } ! public static string GetOppositeSignedTicker( string signedTicker ) ! { ! string oppositeSignedTicker = ""; ! if ( SignedTicker.IsShort( signedTicker ) ) ! oppositeSignedTicker = SignedTicker.GetTicker( signedTicker ); ! if ( SignedTicker.IsLong( signedTicker ) ) ! oppositeSignedTicker = "-" + SignedTicker.GetTicker( signedTicker ); ! return oppositeSignedTicker; ! } ! public static OrderType GetMarketOrderType( string signedTicker ) { ! OrderType orderType = OrderType.MarketBuy; ! if ( SignedTicker.IsShort( signedTicker ) ) ! orderType = OrderType.MarketSellShort; ! return orderType; } ! public static double GetCloseToCloseDailyReturn( ! string signedTicker , DateTime today ) { ! string ticker = SignedTicker.GetTicker( signedTicker ); HistoricalAdjustedQuoteProvider historicalAdjustedQuoteProvider = new HistoricalAdjustedQuoteProvider(); --- 169,193 ---- return ticker; } ! // public static bool IsShort( string signedTicker ) ! // { ! // return ( signedTicker.StartsWith( "-" ) ); ! // } ! // public static bool IsLong( string signedTicker ) ! // { ! // return ( !SignedTicker.IsShort( signedTicker ) ); ! // } ! public OrderType MarketOrderType { ! get ! { ! OrderType orderType = OrderType.MarketBuy; ! if ( this.IsShort ) ! orderType = OrderType.MarketSellShort; ! return orderType; ! } } ! public double GetCloseToCloseDailyReturn( DateTime today ) { ! string ticker = this.Ticker; HistoricalAdjustedQuoteProvider historicalAdjustedQuoteProvider = new HistoricalAdjustedQuoteProvider(); *************** *** 113,117 **** ( todayMarketValueAtClose / yesterdayMarketValueAtClose ) - 1; double dailyReturn; ! if ( SignedTicker.IsShort( signedTicker ) ) // signedTicker represents a short position dailyReturn = - dalyReturnForLongPosition; --- 204,208 ---- ( todayMarketValueAtClose / yesterdayMarketValueAtClose ) - 1; double dailyReturn; ! if ( this.IsShort ) // signedTicker represents a short position dailyReturn = - dalyReturnForLongPosition; *************** *** 155,160 **** #region getCloseToClosePortfolioReturn_setReturns ! private static double getCloseToClosePortfolioReturn_setReturns_getReturn(int returnDay, ! string[] signedTickers,double[] tickersWeights,Quotes[] tickersQuotes ) { double returnValue = 0.0; --- 246,252 ---- #region getCloseToClosePortfolioReturn_setReturns ! private static double getCloseToClosePortfolioReturn_setReturns_getReturn( ! int returnDay, string[] signedTickers , ! double[] tickersWeights, Quotes[] tickersQuotes ) { double returnValue = 0.0; *************** *** 162,166 **** for(int indexForTicker = 0; indexForTicker<signedTickers.Length; indexForTicker++) { ! if(SignedTicker.IsLong(signedTickers[indexForTicker])) signOfTicker = 1.0f; else --- 254,260 ---- for(int indexForTicker = 0; indexForTicker<signedTickers.Length; indexForTicker++) { ! SignedTicker signedTicker = ! new SignedTicker( signedTickers[indexForTicker] ); ! if( signedTicker.IsLong ) signOfTicker = 1.0f; else *************** *** 250,276 **** /// <param name="startDate">Start date for the period for which return has to be computed</param> /// <param name="endDate">End date for the period for which return has to be computed</param> ! public static double GetCloseToClosePortfolioReturn( string[] signedTickers , ! double[] tickersWeights , ! SortedList commonMarketDays ) ! { ! const double initialEquity = 1.0; ! double equityValue = initialEquity; ! Quotes[] tickersQuotes = new Quotes[ signedTickers.Length ]; ! for( int i = 0 ; i < signedTickers.Length ; i++ ) ! { ! tickersQuotes[ i ] = ! new Quotes( SignedTicker.GetTicker( (string)signedTickers[ i ] ) , ! commonMarketDays ); ! } ! double[] returns = new double[ tickersQuotes[0].Rows.Count ]; ! getCloseToClosePortfolioReturn_setReturns( returns , signedTickers , ! tickersWeights , tickersQuotes); ! for( int i = 0 ; i < returns.Length ; i++ ) ! equityValue = ! equityValue + equityValue * returns[i]; ! ! return (equityValue - initialEquity)/initialEquity; ! } ! /// <summary> /// Gets portfolio's return, for the given tickers, considering only --- 344,370 ---- /// <param name="startDate">Start date for the period for which return has to be computed</param> /// <param name="endDate">End date for the period for which return has to be computed</param> ! // public static double GetCloseToClosePortfolioReturn( string[] signedTickers , ! // double[] tickersWeights , ! // SortedList commonMarketDays ) ! // { ! // const double initialEquity = 1.0; ! // double equityValue = initialEquity; ! // Quotes[] tickersQuotes = new Quotes[ signedTickers.Length ]; ! // for( int i = 0 ; i < signedTickers.Length ; i++ ) ! // { ! // tickersQuotes[ i ] = ! // new Quotes( SignedTicker.GetTicker( (string)signedTickers[ i ] ) , ! // commonMarketDays ); ! // } ! // double[] returns = new double[ tickersQuotes[0].Rows.Count ]; ! // getCloseToClosePortfolioReturn_setReturns( returns , signedTickers , ! // tickersWeights , tickersQuotes); ! // for( int i = 0 ; i < returns.Length ; i++ ) ! // equityValue = ! // equityValue + equityValue * returns[i]; ! // ! // return (equityValue - initialEquity)/initialEquity; ! // } ! // /// <summary> /// Gets portfolio's return, for the given tickers, considering only *************** *** 280,295 **** /// <param name="commonMarketDays"></param> /// <returns></returns> ! public static double GetCloseToClosePortfolioReturn( ! string[] signedTickers, ! SortedList commonMarketDays ) ! { ! double[] tickersWeights = new double[signedTickers.Length]; ! for(int i = 0; i<signedTickers.Length; i++) ! tickersWeights[i] = 1.0/signedTickers.Length; ! ! return GetCloseToClosePortfolioReturn( ! signedTickers , tickersWeights , commonMarketDays ); ! } ! private static double getLastNightPortfolioReturn(float[] tickersLastNightReturns, double[] tickersWeights) --- 374,389 ---- /// <param name="commonMarketDays"></param> /// <returns></returns> ! // public static double GetCloseToClosePortfolioReturn( ! // string[] signedTickers, ! // SortedList commonMarketDays ) ! // { ! // double[] tickersWeights = new double[signedTickers.Length]; ! // for(int i = 0; i<signedTickers.Length; i++) ! // tickersWeights[i] = 1.0/signedTickers.Length; ! // ! // return GetCloseToClosePortfolioReturn( ! // signedTickers , tickersWeights , commonMarketDays ); ! // } ! // private static double getLastNightPortfolioReturn(float[] tickersLastNightReturns, double[] tickersWeights) *************** *** 373,406 **** return closeToCloseReturn; } ! private static double getMultiplier( string signedTicker ) ! { ! double multiplier = 1.0; ! if ( IsShort( signedTicker ) ) ! multiplier = -multiplier; ! return multiplier; ! } ! private static double getCloseToClosePortfolioReturn( ! string[] signedTickers , SortedList datesForReturnComputation , int i ) ! { ! double dailyReturn = 0.0; ! foreach ( String signedTicker in signedTickers ) ! dailyReturn += getMultiplier( signedTicker ) * ! getCloseToCloseReturn( GetTicker( signedTicker ) , ! datesForReturnComputation , i ) / ! signedTickers.Length; // every position is considered with same weight ! return dailyReturn; ! } ! private static double[] getCloseToClosePortfolioReturns( ! string[] signedTickers , SortedList datesForReturnComputation ) ! { ! // the return for first DateTime cannot be computed so the returned ! // array will have one element less the datesForReturnComputation ! double[] closeToClosePortfolioReturns = ! new double[ datesForReturnComputation.Count - 1 ]; ! for ( int i=0 ; i < closeToClosePortfolioReturns.Length ; i++ ) ! closeToClosePortfolioReturns[ i ] = getCloseToClosePortfolioReturn( ! signedTickers , datesForReturnComputation , i ); ! return closeToClosePortfolioReturns; ! } private static double[] getCloseToClosePortfolioReturns( ICollection signedTickers, SortedList datesForReturnComputation ) --- 467,500 ---- return closeToCloseReturn; } ! // private static double getMultiplier( string signedTicker ) ! // { ! // double multiplier; ! // if ( IsShort( signedTicker ) ) ! // multiplier = -multiplier; ! // return multiplier; ! // } ! // private static double getCloseToClosePortfolioReturn( ! // string[] signedTickers , SortedList datesForReturnComputation , int i ) ! // { ! // double dailyReturn = 0.0; ! // foreach ( String signedTicker in signedTickers ) ! // dailyReturn += getMultiplier( signedTicker ) * ! // getCloseToCloseReturn( GetTicker( signedTicker ) , ! // datesForReturnComputation , i ) / ! // signedTickers.Length; // every position is considered with same weight ! // return dailyReturn; ! // } ! // private static double[] getCloseToClosePortfolioReturns( ! // string[] signedTickers , SortedList datesForReturnComputation ) ! // { ! // // the return for first DateTime cannot be computed so the returned ! // // array will have one element less the datesForReturnComputation ! // double[] closeToClosePortfolioReturns = ! // new double[ datesForReturnComputation.Count - 1 ]; ! // for ( int i=0 ; i < closeToClosePortfolioReturns.Length ; i++ ) ! // closeToClosePortfolioReturns[ i ] = getCloseToClosePortfolioReturn( ! // signedTickers , datesForReturnComputation , i ); ! // return closeToClosePortfolioReturns; ! // } private static double[] getCloseToClosePortfolioReturns( ICollection signedTickers, SortedList datesForReturnComputation ) *************** *** 452,455 **** --- 546,555 ---- } } + public static string GetOppositeSignedTicker( string stringForSignedTicker ) + { + SignedTicker signedTicker = new SignedTicker( stringForSignedTicker ); + SignedTicker oppositeSignedTicker = signedTicker.OppositeSignedTicker; + return oppositeSignedTicker.Ticker; + } } } |
|
From: Glauco S. <gla...@us...> - 2007-08-07 16:44:47
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/ArbitrageTesting/OverReactionHypothesis/SimpleOHTest In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv19350/b7_Scripts/ArbitrageTesting/OverReactionHypothesis/SimpleOHTest Modified Files: EndOfDayTimerHandlerSimpleOHTest.cs Log Message: SignedTicker instance method are used now, static method were used in previous revision Index: EndOfDayTimerHandlerSimpleOHTest.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/ArbitrageTesting/OverReactionHypothesis/SimpleOHTest/EndOfDayTimerHandlerSimpleOHTest.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EndOfDayTimerHandlerSimpleOHTest.cs 9 Apr 2007 18:23:49 -0000 1.1 --- EndOfDayTimerHandlerSimpleOHTest.cs 7 Aug 2007 16:44:43 -0000 1.2 *************** *** 84,89 **** int tickerPosition ) { ! string ticker = ! SignedTicker.GetTicker(tickers[tickerPosition]); double cashForSinglePosition = this.account.CashAmount / this.chosenTickers.Length; --- 84,89 ---- int tickerPosition ) { ! SignedTicker signedTicker = new SignedTicker( tickers[tickerPosition] ); ! string ticker = signedTicker.Ticker; double cashForSinglePosition = this.account.CashAmount / this.chosenTickers.Length; *************** *** 91,96 **** Convert.ToInt64( Math.Floor( cashForSinglePosition / this.account.DataStreamer.GetCurrentBid( ticker ) ) ); Order order = ! new Order( ! SignedTicker.GetMarketOrderType(tickers[tickerPosition]), new Instrument( ticker ) , quantity ); this.orders.Add(order); --- 91,95 ---- Convert.ToInt64( Math.Floor( cashForSinglePosition / this.account.DataStreamer.GetCurrentBid( ticker ) ) ); Order order = ! new Order( signedTicker.MarketOrderType , new Instrument( ticker ) , quantity ); this.orders.Add(order); |
|
From: Glauco S. <gla...@us...> - 2007-08-07 16:40:02
|
Update of /cvsroot/quantproject/QuantProject/b4_Business In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16760/b4_Business Modified Files: b4_Business.csproj Log Message: a2_Strategies\SignedTickers.cs has been added Index: b4_Business.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/b4_Business.csproj,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** b4_Business.csproj 13 Jul 2007 10:02:55 -0000 1.41 --- b4_Business.csproj 7 Aug 2007 16:39:56 -0000 1.42 *************** *** 613,616 **** --- 613,621 ---- /> <File + RelPath = "a2_Strategies\SignedTickers.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "a2_Strategies\TradingSystem.cs" SubType = "Code" |
|
From: Glauco S. <gla...@us...> - 2007-08-07 16:38:36
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16230/b4_Business/a2_Strategies Added Files: SignedTickers.cs Log Message: strongly typed collection of SignedTicker(s) --- NEW FILE: SignedTickers.cs --- /* QuantProject - Quantitative Finance Library SignedTicker.cs Copyright (C) 2007 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; namespace QuantProject.Business.Strategies { /// <summary> /// strongly typed collection of SignedTicker(s) /// </summary> public class SignedTickers : System.Collections.CollectionBase { public double[] Multipliers { get { double[] multipliers = new double[ List.Count ]; for ( int i = 0 ; i < List.Count ; i++ ) multipliers[ i ] = ((SignedTicker)(List[ i ])).Multiplier; return multipliers; } } public SignedTickers() { // // TODO: Add constructor logic here // } /// <summary> /// /// </summary> /// <param name="signedTickers">string of semicolon separated signed tickers</param> public SignedTickers( string signedTickers ) { this.addSignedTickers( signedTickers ); } /// <summary> /// /// </summary> /// <param name="signedTickers">array of SignedTicker(s)</param> public SignedTickers( string[] signedTickers ) { this.addSignedTickers( signedTickers ); } private void addSignedTickers( string signedTickers ) { string[] arrayForSignedTickers = signedTickers.Split( ';' ); this.addSignedTickers( arrayForSignedTickers ); } private void addSignedTickers( string[] signedTickers ) { foreach ( string signedTicker in signedTickers ) this.Add( new SignedTicker( signedTicker ) ); } public SignedTicker this[ int index ] { get { return( (SignedTicker) this.List[ index ] ); } set { this.List[ index ] = value; } } public void Add( SignedTicker signedTicker ) { this.List.Add( signedTicker ); } } } |
|
From: Glauco S. <gla...@us...> - 2007-08-04 20:00:28
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16983/b7_Scripts/WalkForwardTesting/WalkForwardLag Modified Files: RunWalkForwardLag.cs Log Message: Fixed a private method's name Index: RunWalkForwardLag.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/RunWalkForwardLag.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** RunWalkForwardLag.cs 11 Jun 2007 17:43:51 -0000 1.9 --- RunWalkForwardLag.cs 4 Aug 2007 20:00:24 -0000 1.10 *************** *** 168,173 **** this.account.AddCash( 30000 ); } ! #region oneHourAfterMarketCloseEventHandler ! private void oneHourAfterMarketCloseEventHandler_handleProgessBarForm( IEndOfDayTimer endOfDayTimer ) { --- 168,173 ---- this.account.AddCash( 30000 ); } ! #region marketCloseEventHandler ! private void marketCloseEventHandler_handleProgessBarForm( IEndOfDayTimer endOfDayTimer ) { *************** *** 275,279 **** else // the simulation has not reached the ending date, yet ! this.oneHourAfterMarketCloseEventHandler_handleProgessBarForm( ( IEndOfDayTimer )sender ); } --- 275,279 ---- else // the simulation has not reached the ending date, yet ! this.marketCloseEventHandler_handleProgessBarForm( ( IEndOfDayTimer )sender ); } |
|
From: Glauco S. <gla...@us...> - 2007-08-04 19:59:13
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16358/b4_Business/a2_Strategies/returnsManagement Modified Files: ReturnsManager.cs Log Message: Bug fixed: returns were not properly computed Index: ReturnsManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/ReturnsManager.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ReturnsManager.cs 1 Aug 2007 23:11:02 -0000 1.2 --- ReturnsManager.cs 4 Aug 2007 19:59:08 -0000 1.3 *************** *** 134,153 **** return areAllCovered; } ! private float selectReturnWithRespectToTheTimeLine( History returns , int i ) { ! DateTime currentDateTimeForReturn = ! (DateTime)this.timeLineForQuotes.GetByIndex( i ); ! return (float)returns[ currentDateTimeForReturn ]; } ! private float[] selectReturnsWithRespectToTheTimeLine( History returns ) { // TO DO: this method is n log n, it could be implemented to // be have a linear complexity!!! float[] returnsWithRespectToTheTimeLine = ! new float[ this.timeLineForQuotes.Count ]; ! for ( int i = 0 ; i < this.timeLineForQuotes.Count ; i++ ) returnsWithRespectToTheTimeLine[ i ] = ! this.selectReturnWithRespectToTheTimeLine( returns , i ); return returnsWithRespectToTheTimeLine; } --- 134,154 ---- return areAllCovered; } ! private float selectReturnWithRespectToTheTimeLine( History quotes , int i ) { ! float currentQuote = (float)quotes.GetByIndex( i ); ! float nextQuote = (float)quotes.GetByIndex( i + 1 ); ! float currentReturn = nextQuote / currentQuote - 1; ! return currentReturn; } ! private float[] selectReturnsWithRespectToTheTimeLine( History quotes ) { // TO DO: this method is n log n, it could be implemented to // be have a linear complexity!!! float[] returnsWithRespectToTheTimeLine = ! new float[ this.timeLineForQuotes.Count - 1 ]; ! for ( int i = 0 ; i < this.timeLineForQuotes.Count - 1 ; i++ ) returnsWithRespectToTheTimeLine[ i ] = ! this.selectReturnWithRespectToTheTimeLine( quotes , i ); return returnsWithRespectToTheTimeLine; } |
|
From: Glauco S. <gla...@us...> - 2007-08-04 19:58:16
|
Update of /cvsroot/quantproject/QuantProject/b5_Presentation In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15880/b5_Presentation Modified Files: b5_Presentation.csproj Log Message: VSNet automatic change Index: b5_Presentation.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b5_Presentation/b5_Presentation.csproj,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** b5_Presentation.csproj 1 Aug 2007 22:50:56 -0000 1.37 --- b5_Presentation.csproj 4 Aug 2007 19:58:11 -0000 1.38 *************** *** 169,173 **** <File RelPath = "Charting\Chart.cs" ! SubType = "Code" BuildAction = "Compile" /> --- 169,173 ---- <File RelPath = "Charting\Chart.cs" ! SubType = "UserControl" BuildAction = "Compile" /> |
|
From: Glauco S. <gla...@us...> - 2007-08-04 19:57:55
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15387/b1_ADT/Optimizing/Genetic Modified Files: GeneticOptimizer.cs Log Message: Added a (commented) line, to be used if you get an exception from the Sort method and you want to break to the right code line Index: GeneticOptimizer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/GeneticOptimizer.cs,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** GeneticOptimizer.cs 19 Jun 2007 19:18:38 -0000 1.24 --- GeneticOptimizer.cs 4 Aug 2007 19:57:47 -0000 1.25 *************** *** 297,300 **** --- 297,303 ---- private void sortCurrentGenerationAndFireNewGenerationEvent() { + // comment out the following line if you have an exception + // in the Sort method and you want to break to the proper line + // double fitness = ((Genome) this.currentGeneration[ 0 ]).Fitness; this.currentGeneration.Sort(this.genomeComparer); if(this.NewGeneration != null) |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv12218/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio Modified Files: WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs Log Message: A logical error has been fixed: this.setChosenPositions_usingTheGeneticOptimizer() is used now, instead of this.setWeightedPositions_usingTheGeneticOptimizer() Index: WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs 13 Jul 2007 10:13:06 -0000 1.4 --- WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs 1 Aug 2007 23:15:39 -0000 1.5 *************** *** 125,129 **** generationNumberForGeneticOptimizer; } ! #region setWeightedPositions_usingTheGeneticOptimizer private History getTimeLineForOptimization( EndOfDayDateTime now ) { --- 125,129 ---- generationNumberForGeneticOptimizer; } ! #region setChosenPositions_usingTheGeneticOptimizer private History getTimeLineForOptimization( EndOfDayDateTime now ) { *************** *** 150,159 **** // wFLagWeightedPositions.PortfolioWeightedPositions; // } ! private void setSignedTickers_setTickersFromGenome( ! IGenomeManager genomeManager , ! Genome genome ) { this.wFLagChosenPositions = ! ( WFLagChosenPositions )genomeManager.Decode( genome ); // this.setWeightedPositions( wFLagWeightedPositions ); // this.drivingWeightedPositions = --- 150,174 ---- // wFLagWeightedPositions.PortfolioWeightedPositions; // } ! private WFLagWeightedPositions getWFLagWeightedPositions_FromDecodableGenome( ! IGenomeManager genomeManager , Genome genome ) { + object wFLagWeightedPositions = + genomeManager.Decode( genome ); + if ( !(wFLagWeightedPositions is WFLagWeightedPositions) ) + throw new Exception( "The genome is not a WFLagWeightedPositions. " + + "It should happen only if the genome is undecodable. This " + + "should never happen for the best genome." ); + return (WFLagWeightedPositions)wFLagWeightedPositions; + } + private void setChosenPositions_FromDecodableGenome( + IGenomeManager genomeManager , Genome genome , + EndOfDayDateTime now ) + { + WFLagWeightedPositions wFLagWeightedPositions = + this.getWFLagWeightedPositions_FromDecodableGenome( + genomeManager , genome ); this.wFLagChosenPositions = ! new WFLagChosenPositions( ! wFLagWeightedPositions , now.DateTime ); // this.setWeightedPositions( wFLagWeightedPositions ); // this.drivingWeightedPositions = *************** *** 162,166 **** // wFLagWeightedPositions.PortfolioWeightedPositions; } ! public virtual void setWeightedPositions_usingTheGeneticOptimizer( WFLagEligibleTickers eligibleTickersForDrivingPositions , EndOfDayDateTime now ) --- 177,181 ---- // wFLagWeightedPositions.PortfolioWeightedPositions; } ! public virtual void setChosenPositions_usingTheGeneticOptimizer( WFLagEligibleTickers eligibleTickersForDrivingPositions , EndOfDayDateTime now ) *************** *** 193,203 **** geneticOptimizer.Run( false ); ! this.setSignedTickers_setTickersFromGenome( ! genomeManager , geneticOptimizer.BestGenome ); // this.generation = geneticOptimizer.BestGenome.Generation; } ! #endregion private void chosePositions_checkParameters( WFLagEligibleTickers eligibleTickersForDrivingPositions , --- 208,218 ---- geneticOptimizer.Run( false ); ! this.setChosenPositions_FromDecodableGenome( ! genomeManager , geneticOptimizer.BestGenome , now ); // this.generation = geneticOptimizer.BestGenome.Generation; } ! #endregion //setChosenPositions_usingTheGeneticOptimizer private void chosePositions_checkParameters( WFLagEligibleTickers eligibleTickersForDrivingPositions , *************** *** 228,232 **** this.chosePositions_checkParameters( eligibleTickersForDrivingPositions , now ); ! this.setWeightedPositions_usingTheGeneticOptimizer( eligibleTickersForDrivingPositions , now ); --- 243,247 ---- this.chosePositions_checkParameters( eligibleTickersForDrivingPositions , now ); ! this.setChosenPositions_usingTheGeneticOptimizer( eligibleTickersForDrivingPositions , now ); |
|
From: Glauco S. <gla...@us...> - 2007-08-01 23:13:58
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagDebugger In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv11395/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagDebugger Modified Files: WFLagChosenPositions.cs Log Message: A new constructor has been added: public WFLagChosenPositions( WFLagWeightedPositions wFLagWeightedPositions , DateTime lastOptimizationDate ) Index: WFLagChosenPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagDebugger/WFLagChosenPositions.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** WFLagChosenPositions.cs 18 Feb 2007 01:03:36 -0000 1.4 --- WFLagChosenPositions.cs 1 Aug 2007 23:13:54 -0000 1.5 *************** *** 93,96 **** --- 93,107 ---- this.lastOptimizationDate = lastOptimizationDate; } + public WFLagChosenPositions( WFLagWeightedPositions wFLagWeightedPositions , + DateTime lastOptimizationDate ) + { + // this.drivingPositions = + // this.copy( wFLagChosenTickers.DrivingWeightedPositions ); + // this.portfolioPositions = + // this.copy( wFLagChosenTickers.PortfolioWeightedPositions ); + this.drivingWeightedPositions = wFLagWeightedPositions.DrivingWeightedPositions; + this.portfolioWeightedPositions = wFLagWeightedPositions.PortfolioWeightedPositions; + this.lastOptimizationDate = lastOptimizationDate; + } public WFLagChosenPositions( WeightedPositions drivingWeightedPositions , |
|
From: Glauco S. <gla...@us...> - 2007-08-01 23:12:50
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10967/b7_Scripts/WalkForwardTesting/WalkForwardLag Modified Files: WeightedPositions.cs Log Message: - returnsManager.NumberOfReturns is used now Index: WeightedPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositions.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** WeightedPositions.cs 13 Jul 2007 10:10:45 -0000 1.5 --- WeightedPositions.cs 1 Aug 2007 23:12:46 -0000 1.6 *************** *** 440,444 **** float[] returns = new float[ returnsManager.TimeLine.Count - 1 ]; ! for ( int i = 0 ; i < returnsManager.TimeLine.Count ; i++ ) returns[ i ] = this.GetReturn( i , returnsManager ); return returns; --- 440,444 ---- float[] returns = new float[ returnsManager.TimeLine.Count - 1 ]; ! for ( int i = 0 ; i < returnsManager.NumberOfReturns ; i++ ) returns[ i ] = this.GetReturn( i , returnsManager ); return returns; |
|
From: Glauco S. <gla...@us...> - 2007-08-01 23:11:06
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10130/b4_Business/a2_Strategies/returnsManagement Modified Files: ReturnsManager.cs Log Message: - public int NumberOfReturns has been added - History.GetDateTime() is now used, to avoid casting and make runtime errors unlikely - minor bug fixes Index: ReturnsManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/ReturnsManager.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ReturnsManager.cs 13 Jul 2007 09:47:47 -0000 1.1 --- ReturnsManager.cs 1 Aug 2007 23:11:02 -0000 1.2 *************** *** 54,60 **** } protected DateTime firstDateTime { ! get { return (DateTime)this.timeLineForQuotes[ 0 ]; } } protected DateTime lastDateTime --- 54,67 ---- } + /// <summary> + /// Number of returns, that is TimeLine's elements minus 1 + /// </summary> + public int NumberOfReturns + { + get { return this.TimeLine.Count - 1; } + } protected DateTime firstDateTime { ! get { return this.timeLineForQuotes.GetDateTime( 0 ); } } protected DateTime lastDateTime *************** *** 63,67 **** { int lastIndex = this.timeLineForQuotes.Count - 1; ! return (DateTime)this.timeLineForQuotes[ lastIndex ]; } } --- 70,74 ---- { int lastIndex = this.timeLineForQuotes.Count - 1; ! return this.timeLineForQuotes.GetDateTime( lastIndex ); } } *************** *** 91,95 **** { // TO DO: let WFLagEligibleTickers use this class also!!! ! this.timeLineForQuotes = timeLineForQuotes; this.commonInitialization(); } --- 98,102 ---- { // TO DO: let WFLagEligibleTickers use this class also!!! ! this.timeLineForQuotes = timeLine; this.commonInitialization(); } *************** *** 122,131 **** { bool areAllCovered = true; ! foreach ( DateTime dateTime in this.timeLineForQuotes ) if ( !returns.ContainsKey( dateTime ) ) areAllCovered = false; return areAllCovered; } ! private float selectReturnOnValidDateTime( History returns , int i ) { --- 129,138 ---- { bool areAllCovered = true; ! foreach ( DateTime dateTime in this.timeLineForQuotes.TimeLine ) if ( !returns.ContainsKey( dateTime ) ) areAllCovered = false; return areAllCovered; } ! private float selectReturnWithRespectToTheTimeLine( History returns , int i ) { *************** *** 134,152 **** return (float)returns[ currentDateTimeForReturn ]; } ! private float[] selectReturnsOnValidDateTimes( History returns ) { // TO DO: this method is n log n, it could be implemented to // be have a linear complexity!!! ! float[] returnsOnValidDateTimes = new float[ this.timeLineForQuotes.Count ]; for ( int i = 0 ; i < this.timeLineForQuotes.Count ; i++ ) ! returnsOnValidDateTimes[ i ] = ! this.selectReturnOnValidDateTime( returns , i ); ! return returnsOnValidDateTimes; } ! private void setReturnsActually( string ticker , History returns ) { float[] arrayOfReturns = ! this.selectReturnsOnValidDateTimes( returns ); this.tickersReturns.Add( ticker , arrayOfReturns ); } --- 141,159 ---- return (float)returns[ currentDateTimeForReturn ]; } ! private float[] selectReturnsWithRespectToTheTimeLine( History returns ) { // TO DO: this method is n log n, it could be implemented to // be have a linear complexity!!! ! float[] returnsWithRespectToTheTimeLine = new float[ this.timeLineForQuotes.Count ]; for ( int i = 0 ; i < this.timeLineForQuotes.Count ; i++ ) ! returnsWithRespectToTheTimeLine[ i ] = ! this.selectReturnWithRespectToTheTimeLine( returns , i ); ! return returnsWithRespectToTheTimeLine; } ! private void setReturnsActually( string ticker , History quotes ) { float[] arrayOfReturns = ! this.selectReturnsWithRespectToTheTimeLine( quotes ); this.tickersReturns.Add( ticker , arrayOfReturns ); } *************** *** 176,180 **** } #endregion GetReturns ! #region GetReturns /// <summary> /// Gives out the returnIndex_th return for the given ticker --- 183,187 ---- } #endregion GetReturns ! #region GetReturn /// <summary> /// Gives out the returnIndex_th return for the given ticker *************** *** 223,227 **** private float getReturnsStandardDeviation( string ticker ) { ! return (float)this.tickersReturnsStandardDeviations[ ticker ]; } /// <summary> --- 230,234 ---- private float getReturnsStandardDeviation( string ticker ) { ! return Convert.ToSingle( this.tickersReturnsStandardDeviations[ ticker ] ); } /// <summary> |
|
From: Glauco S. <gla...@us...> - 2007-08-01 22:58:12
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Histories In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv31239/b1_ADT/Histories Modified Files: History.cs Log Message: - public ICollection TimeLine has been added - public DateTime GetDateTime( int index ) has been added Index: History.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Histories/History.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** History.cs 18 Jun 2006 15:28:11 -0000 1.10 --- History.cs 1 Aug 2007 22:58:03 -0000 1.11 *************** *** 36,39 **** --- 36,47 ---- public class History : AdvancedSortedList { + /// <summary> + /// Returns the ICollection of DateTimes on which the + /// history is built + /// </summary> + public ICollection TimeLine + { + get { return this.Keys; } + } public History() : base() { *************** *** 81,84 **** --- 89,101 ---- /// <summary> + /// Returns the i-1_th element in the history timeline + /// </summary> + /// <param name="index"></param> + /// <returns></returns> + public DateTime GetDateTime( int index ) + { + return (DateTime)this.GetKey( index ); + } + /// <summary> /// Add an history item, if no collision (contemporary events) is expected /// </summary> |
|
From: Glauco S. <gla...@us...> - 2007-08-01 22:51:00
|
Update of /cvsroot/quantproject/QuantProject/b5_Presentation In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv27426/b5_Presentation Modified Files: b5_Presentation.csproj Log Message: Minor change, automatically applied by VSNet Index: b5_Presentation.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b5_Presentation/b5_Presentation.csproj,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** b5_Presentation.csproj 11 Jun 2007 17:54:59 -0000 1.36 --- b5_Presentation.csproj 1 Aug 2007 22:50:56 -0000 1.37 *************** *** 131,139 **** /> <Reference - Name = "NPlot" - AssemblyName = "NPlot" - HintPath = "..\..\..\..\..\Documents and Settings\Glauco\Desktop\NPlot\NPlot.dll" - /> - <Reference Name = "Microsoft.Office.Core" Guid = "{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}" --- 131,134 ---- *************** *** 143,146 **** --- 138,146 ---- WrapperTool = "primary" /> + <Reference + Name = "NPlot" + AssemblyName = "NPlot" + HintPath = "..\..\NPlot.dll" + /> </References> </Build> *************** *** 169,173 **** <File RelPath = "Charting\Chart.cs" ! SubType = "UserControl" BuildAction = "Compile" /> --- 169,173 ---- <File RelPath = "Charting\Chart.cs" ! SubType = "Code" BuildAction = "Compile" /> |
|
From: Glauco S. <gla...@us...> - 2007-08-01 22:50:30
|
Update of /cvsroot/quantproject/QuantProject/b3_Data In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv27112/b3_Data Modified Files: b3_Data.csproj Log Message: Minor change, automatically applied by VSNet Index: b3_Data.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/b3_Data.csproj,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** b3_Data.csproj 13 Jul 2007 10:01:56 -0000 1.48 --- b3_Data.csproj 1 Aug 2007 22:50:17 -0000 1.49 *************** *** 144,148 **** <File RelPath = "ExtendedDataTable.cs" ! SubType = "Component" BuildAction = "Compile" /> --- 144,148 ---- <File RelPath = "ExtendedDataTable.cs" ! SubType = "Code" BuildAction = "Compile" /> |
|
From: Glauco S. <gla...@us...> - 2007-07-13 10:18:08
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EquityEvaluation In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv31934/b4_Business/a2_Strategies/EquityEvaluation Modified Files: WinningPeriods.cs Log Message: GetReturnsEvaluation returns a float now (it returned a double in the previous version) Index: WinningPeriods.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EquityEvaluation/WinningPeriods.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WinningPeriods.cs 3 Nov 2006 16:28:17 -0000 1.1 --- WinningPeriods.cs 13 Jul 2007 10:18:03 -0000 1.2 *************** *** 34,38 **** { } ! public double GetReturnsEvaluation( double[] returns ) { int winningPeriods = 0; --- 34,38 ---- { } ! public float GetReturnsEvaluation( float[] returns ) { int winningPeriods = 0; *************** *** 45,50 **** losingPeriods++; } ! return ( Convert.ToDouble( winningPeriods ) / ! Convert.ToDouble( winningPeriods + losingPeriods ) ); } } --- 45,50 ---- losingPeriods++; } ! return ( Convert.ToSingle( winningPeriods ) / ! Convert.ToSingle( winningPeriods + losingPeriods ) ); } } |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv31039/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio Modified Files: WFLagGenomeManagerForFixedPortfolioWithNormalDrivingAndPortfolio.cs Log Message: GetFitnessValue returns a float now (it returned a double in the previous version) Index: WFLagGenomeManagerForFixedPortfolioWithNormalDrivingAndPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio/WFLagGenomeManagerForFixedPortfolioWithNormalDrivingAndPortfolio.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WFLagGenomeManagerForFixedPortfolioWithNormalDrivingAndPortfolio.cs 24 Jun 2007 21:34:55 -0000 1.2 --- WFLagGenomeManagerForFixedPortfolioWithNormalDrivingAndPortfolio.cs 13 Jul 2007 10:16:59 -0000 1.3 *************** *** 25,31 **** --- 25,33 ---- using System.Data; + using QuantProject.ADT.Histories; using QuantProject.ADT.Optimizing.Genetic; using QuantProject.ADT.Statistics; using QuantProject.Business.Strategies; + using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Strategies.EquityEvaluation; *************** *** 45,57 **** private int numberOfDrivingPositions; private string[] portfolioSignedTickers; // private int numberOfEligibleTickersForDrivingWeightedPositions; protected DataTable eligibleTickersForDrivingWeightedPositions; protected DataTable eligibleTickersForPortfolioWeightedPositions; ! private DateTime firstOptimizationDateForDrivingPositions; ! private DateTime lastOptimizationDate; private double minimumPositionWeight; ! protected WFLagCandidates wFLagCandidates; private IEquityEvaluator equityEvaluator; --- 47,66 ---- private int numberOfDrivingPositions; private string[] portfolioSignedTickers; + private History timeLineForOptimization; // this time line goes from + // the first optimization date for driving positions to the + // last optimization date; this optimization is meant to be + // launched one hour after the last market close + + // private DateTime firstOptimizationDateForDrivingPositions; + // private DateTime lastOptimizationDate; // private int numberOfEligibleTickersForDrivingWeightedPositions; protected DataTable eligibleTickersForDrivingWeightedPositions; protected DataTable eligibleTickersForPortfolioWeightedPositions; ! // private DateTime firstOptimizationDateForDrivingPositions; ! // private DateTime lastOptimizationDate; private double minimumPositionWeight; ! // protected WFLagCandidates wFLagCandidates; private IEquityEvaluator equityEvaluator; *************** *** 59,62 **** --- 68,72 ---- private WFLagMeaningForUndecodableGenomes wFLagMeaningForUndecodableGenomes; private string[] tickersForPortfolioPositions; + private CloseToCloseReturnsManager closeToCloseReturnsManager; *************** *** 89,94 **** DataTable eligibleTickersForDrivingWeightedPositions , string[] portfolioSignedTickers , ! DateTime firstOptimizationDateForDrivingPositions , ! DateTime lastOptimizationDate , IEquityEvaluator equityEvaluator , int seedForRandomGenerator ) --- 99,103 ---- DataTable eligibleTickersForDrivingWeightedPositions , string[] portfolioSignedTickers , ! History timeLineForOptimization , IEquityEvaluator equityEvaluator , int seedForRandomGenerator ) *************** *** 103,109 **** // eligibleTickersForPortfolioWeightedPositions; this.portfolioSignedTickers = portfolioSignedTickers; ! this.firstOptimizationDateForDrivingPositions = ! firstOptimizationDateForDrivingPositions; ! this.lastOptimizationDate = lastOptimizationDate; this.minimumPositionWeight = 0.2; // TO DO this value should become a constructor parameter --- 112,116 ---- // eligibleTickersForPortfolioWeightedPositions; this.portfolioSignedTickers = portfolioSignedTickers; ! this.timeLineForOptimization = timeLineForOptimization; this.minimumPositionWeight = 0.2; // TO DO this value should become a constructor parameter *************** *** 118,124 **** GenomeManagement.SetRandomGenerator( seedForRandomGenerator ); ! this.wFLagCandidates = new WFLagCandidates( ! this.eligibleTickersForDrivingWeightedPositions , ! this.firstOptimizationDateForDrivingPositions , this.lastOptimizationDate ); this.wFLagMeaningForUndecodableGenomes = --- 125,133 ---- GenomeManagement.SetRandomGenerator( seedForRandomGenerator ); ! // this.wFLagCandidates = new WFLagCandidates( ! // this.eligibleTickersForDrivingWeightedPositions , ! // this.firstOptimizationDateForDrivingPositions , this.lastOptimizationDate ); ! this.closeToCloseReturnsManager = ! new CloseToCloseReturnsManager( this.timeLineForOptimization ); this.wFLagMeaningForUndecodableGenomes = *************** *** 158,194 **** } ! private double[] getFitnessValue_getLinearCombinationReturns( WeightedPositions weightedPositions ) { ! // ArrayList enumeratedweightedPositions = ! // this.getEnumeratedWeightedPositions( weightedPositions ); ! int numberOfWeightedPositions = weightedPositions.Count; ! string[] tickers = this.getTickers( weightedPositions ); ! float[] multipliers = this.getMultipliers( weightedPositions ); ! // arrays of close to close returns, one for each signed ticker ! float[][] tickersReturns = ! this.wFLagCandidates.GetTickersReturns( tickers ); ! double[] linearCombinationReturns = ! new double[ tickersReturns[ 0 ].Length ]; ! for( int i = 0; i < linearCombinationReturns.Length ; i++ ) ! // computes linearCombinationReturns[ i ] ! { ! linearCombinationReturns[ i ] = 0; ! for ( int j=0 ; j < weightedPositions.Count ; j++ ) ! { ! double weightedPositionReturn = ! tickersReturns[ j ][ i ] * multipliers[ j ]; ! linearCombinationReturns[ i ] += weightedPositionReturn; ! } ! } ! return linearCombinationReturns; } ! private double[] getFitnessValue_getStrategyReturn( ! double[] drivingPositionsReturns , double[] portfolioPositionsReturns ) { // strategyReturns contains one element less than drivingPositionsReturns, // because there is no strategy for the very first period (at least // one day signal is needed) ! double[] strategyReturns = new double[ portfolioPositionsReturns.Length - 1 ]; for ( int i = 0 ; i < portfolioPositionsReturns.Length - 1 ; i++ ) if ( drivingPositionsReturns[ i ] < 0 ) --- 167,183 ---- } ! private float[] getFitnessValue_getLinearCombinationReturns( WeightedPositions weightedPositions ) { ! return weightedPositions.GetReturns( ! this.closeToCloseReturnsManager ); } ! private float[] getFitnessValue_getStrategyReturn( ! float[] drivingPositionsReturns , float[] portfolioPositionsReturns ) { // strategyReturns contains one element less than drivingPositionsReturns, // because there is no strategy for the very first period (at least // one day signal is needed) ! float[] strategyReturns = new float[ portfolioPositionsReturns.Length - 1 ]; for ( int i = 0 ; i < portfolioPositionsReturns.Length - 1 ; i++ ) if ( drivingPositionsReturns[ i ] < 0 ) *************** *** 207,211 **** } ! private double getFitnessValue( double[] strategyReturns ) { // double fitnessValue = --- 196,200 ---- } ! private float getFitnessValue( float[] strategyReturns ) { // double fitnessValue = *************** *** 215,219 **** // AdvancedFunctions.GetExpectancyScore( // strategyReturns ); ! double fitnessValue = this.equityEvaluator.GetReturnsEvaluation( strategyReturns ); --- 204,208 ---- // AdvancedFunctions.GetExpectancyScore( // strategyReturns ); ! float fitnessValue = this.equityEvaluator.GetReturnsEvaluation( strategyReturns ); *************** *** 227,243 **** } ! public double GetFitnessValue( WFLagWeightedPositions wFLagWeightedPositions ) { ! double[] drivingPositionsReturns = this.getFitnessValue_getLinearCombinationReturns( wFLagWeightedPositions.DrivingWeightedPositions ); ! double[] portfolioPositionsReturns = this.getFitnessValue_getLinearCombinationReturns( wFLagWeightedPositions.PortfolioWeightedPositions ); ! double[] strategyReturns = this.getFitnessValue_getStrategyReturn( drivingPositionsReturns , portfolioPositionsReturns ); ! double fitnessValue = this.getFitnessValue( strategyReturns ); return fitnessValue; } --- 216,232 ---- } ! public float GetFitnessValue( WFLagWeightedPositions wFLagWeightedPositions ) { ! float[] drivingPositionsReturns = this.getFitnessValue_getLinearCombinationReturns( wFLagWeightedPositions.DrivingWeightedPositions ); ! float[] portfolioPositionsReturns = this.getFitnessValue_getLinearCombinationReturns( wFLagWeightedPositions.PortfolioWeightedPositions ); ! float[] strategyReturns = this.getFitnessValue_getStrategyReturn( drivingPositionsReturns , portfolioPositionsReturns ); ! float fitnessValue = this.getFitnessValue( strategyReturns ); return fitnessValue; } *************** *** 496,501 **** Genome genome ) { - double[] weightsForDrivingPositions = this.getWeightsForDrivingPositions( genome ); string[] tickersForDrivingPositions = this.getTickersForDrivingPositions( genome ); return decodeWeightedPositions( weightsForDrivingPositions , --- 485,490 ---- Genome genome ) { string[] tickersForDrivingPositions = this.getTickersForDrivingPositions( genome ); + double[] weightsForDrivingPositions = this.getWeightsForDrivingPositions( genome ); return decodeWeightedPositions( weightsForDrivingPositions , *************** *** 506,511 **** { return WeightedPositions.GetBalancedWeights( this.portfolioSignedTickers , ! this.firstOptimizationDateForDrivingPositions.AddDays( 1 ) , ! this.lastOptimizationDate ); } private WeightedPositions decodePortfolioWeightedPositions( --- 495,499 ---- { return WeightedPositions.GetBalancedWeights( this.portfolioSignedTickers , ! this.closeToCloseReturnsManager ); } private WeightedPositions decodePortfolioWeightedPositions( |
|
From: Glauco S. <gla...@us...> - 2007-07-13 10:16:01
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv30205/b7_Scripts/WalkForwardTesting/WalkForwardLag Modified Files: WFLagGenomeManager.cs Log Message: Several double data have been replaced by float data Index: WFLagGenomeManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagGenomeManager.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** WFLagGenomeManager.cs 3 Jan 2007 23:20:09 -0000 1.8 --- WFLagGenomeManager.cs 13 Jul 2007 10:15:52 -0000 1.9 *************** *** 162,166 **** } ! private double[] getFitnessValue_getLinearCombinationReturns( WeightedPositions weightedPositions ) { --- 162,166 ---- } ! private float[] getFitnessValue_getLinearCombinationReturns( WeightedPositions weightedPositions ) { *************** *** 173,178 **** float[][] tickersReturns = this.wFLagCandidates.GetTickersReturns( tickers ); ! double[] linearCombinationReturns = ! new double[ tickersReturns[ 0 ].Length ]; for( int i = 0; i < linearCombinationReturns.Length ; i++ ) // computes linearCombinationReturns[ i ] --- 173,178 ---- float[][] tickersReturns = this.wFLagCandidates.GetTickersReturns( tickers ); ! float[] linearCombinationReturns = ! new float[ tickersReturns[ 0 ].Length ]; for( int i = 0; i < linearCombinationReturns.Length ; i++ ) // computes linearCombinationReturns[ i ] *************** *** 181,185 **** for ( int j=0 ; j < weightedPositions.Count ; j++ ) { ! double weightedPositionReturn = tickersReturns[ j ][ i ] * multipliers[ j ]; linearCombinationReturns[ i ] += weightedPositionReturn; --- 181,185 ---- for ( int j=0 ; j < weightedPositions.Count ; j++ ) { ! float weightedPositionReturn = tickersReturns[ j ][ i ] * multipliers[ j ]; linearCombinationReturns[ i ] += weightedPositionReturn; *************** *** 188,198 **** return linearCombinationReturns; } ! private double[] getFitnessValue_getStrategyReturn( ! double[] drivingPositionsReturns , double[] portfolioPositionsReturns ) { // strategyReturns contains one element less than drivingPositionsReturns, // because there is no strategy for the very first period (at least // one day signal is needed) ! double[] strategyReturns = new double[ portfolioPositionsReturns.Length - 1 ]; for ( int i = 0 ; i < portfolioPositionsReturns.Length - 1 ; i++ ) if ( drivingPositionsReturns[ i ] < 0 ) --- 188,198 ---- return linearCombinationReturns; } ! private float[] getFitnessValue_getStrategyReturn( ! float[] drivingPositionsReturns , float[] portfolioPositionsReturns ) { // strategyReturns contains one element less than drivingPositionsReturns, // because there is no strategy for the very first period (at least // one day signal is needed) ! float[] strategyReturns = new float[ portfolioPositionsReturns.Length - 1 ]; for ( int i = 0 ; i < portfolioPositionsReturns.Length - 1 ; i++ ) if ( drivingPositionsReturns[ i ] < 0 ) *************** *** 211,215 **** } ! private double getFitnessValue( double[] strategyReturns ) { // double fitnessValue = --- 211,215 ---- } ! private double getFitnessValue( float[] strategyReturns ) { // double fitnessValue = *************** *** 234,244 **** WFLagWeightedPositions wFLagWeightedPositions ) { ! double[] drivingPositionsReturns = this.getFitnessValue_getLinearCombinationReturns( wFLagWeightedPositions.DrivingWeightedPositions ); ! double[] portfolioPositionsReturns = this.getFitnessValue_getLinearCombinationReturns( wFLagWeightedPositions.PortfolioWeightedPositions ); ! double[] strategyReturns = this.getFitnessValue_getStrategyReturn( drivingPositionsReturns , portfolioPositionsReturns ); --- 234,244 ---- WFLagWeightedPositions wFLagWeightedPositions ) { ! float[] drivingPositionsReturns = this.getFitnessValue_getLinearCombinationReturns( wFLagWeightedPositions.DrivingWeightedPositions ); ! float[] portfolioPositionsReturns = this.getFitnessValue_getLinearCombinationReturns( wFLagWeightedPositions.PortfolioWeightedPositions ); ! float[] strategyReturns = this.getFitnessValue_getStrategyReturn( drivingPositionsReturns , portfolioPositionsReturns ); |
|
From: Glauco S. <gla...@us...> - 2007-07-13 10:14:48
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticWithEqualWeights In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv29631/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticWithEqualWeights Modified Files: WFLagGeneticWithEqualWeights.cs Log Message: Several double data have been replaced by float data Index: WFLagGeneticWithEqualWeights.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticWithEqualWeights/WFLagGeneticWithEqualWeights.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WFLagGeneticWithEqualWeights.cs 24 Jun 2007 21:11:46 -0000 1.1 --- WFLagGeneticWithEqualWeights.cs 13 Jul 2007 10:14:44 -0000 1.2 *************** *** 155,159 **** } ! private double[] getFitnessValue_getLinearCombinationReturns( WeightedPositions weightedPositions ) { --- 155,159 ---- } ! private float[] getFitnessValue_getLinearCombinationReturns( WeightedPositions weightedPositions ) { *************** *** 166,171 **** float[][] tickersReturns = this.wFLagCandidates.GetTickersReturns( tickers ); ! double[] linearCombinationReturns = ! new double[ tickersReturns[ 0 ].Length ]; for( int i = 0; i < linearCombinationReturns.Length ; i++ ) // computes linearCombinationReturns[ i ] --- 166,171 ---- float[][] tickersReturns = this.wFLagCandidates.GetTickersReturns( tickers ); ! float[] linearCombinationReturns = ! new float[ tickersReturns[ 0 ].Length ]; for( int i = 0; i < linearCombinationReturns.Length ; i++ ) // computes linearCombinationReturns[ i ] *************** *** 174,178 **** for ( int j=0 ; j < weightedPositions.Count ; j++ ) { ! double weightedPositionReturn = tickersReturns[ j ][ i ] * multipliers[ j ]; linearCombinationReturns[ i ] += weightedPositionReturn; --- 174,178 ---- for ( int j=0 ; j < weightedPositions.Count ; j++ ) { ! float weightedPositionReturn = tickersReturns[ j ][ i ] * multipliers[ j ]; linearCombinationReturns[ i ] += weightedPositionReturn; *************** *** 181,191 **** return linearCombinationReturns; } ! private double[] getFitnessValue_getStrategyReturn( ! double[] drivingPositionsReturns , double[] portfolioPositionsReturns ) { // strategyReturns contains one element less than drivingPositionsReturns, // because there is no strategy for the very first period (at least // one day signal is needed) ! double[] strategyReturns = new double[ portfolioPositionsReturns.Length - 1 ]; for ( int i = 0 ; i < portfolioPositionsReturns.Length - 1 ; i++ ) if ( drivingPositionsReturns[ i ] < 0 ) --- 181,191 ---- return linearCombinationReturns; } ! private float[] getFitnessValue_getStrategyReturn( ! float[] drivingPositionsReturns , float[] portfolioPositionsReturns ) { // strategyReturns contains one element less than drivingPositionsReturns, // because there is no strategy for the very first period (at least // one day signal is needed) ! float[] strategyReturns = new float[ portfolioPositionsReturns.Length - 1 ]; for ( int i = 0 ; i < portfolioPositionsReturns.Length - 1 ; i++ ) if ( drivingPositionsReturns[ i ] < 0 ) *************** *** 204,222 **** } ! private double getFitnessValue( double[] strategyReturns ) { ! // double fitnessValue = // AdvancedFunctions.GetSharpeRatio( // strategyReturns ); ! // double fitnessValue = // AdvancedFunctions.GetExpectancyScore( // strategyReturns ); ! double fitnessValue = this.equityEvaluator.GetReturnsEvaluation( strategyReturns ); ! // double fitnessValue = // this.getFitnessValue_withGoodFinal( strategyReturns ); ! // double fitnessValue = // BasicFunctions.GetSimpleAverage( strategyReturns ) / // ( Math.Pow( BasicFunctions.GetStdDev( strategyReturns ) , 1.3 ) ); --- 204,222 ---- } ! private float getFitnessValue( float[] strategyReturns ) { ! // float fitnessValue = // AdvancedFunctions.GetSharpeRatio( // strategyReturns ); ! // float fitnessValue = // AdvancedFunctions.GetExpectancyScore( // strategyReturns ); ! float fitnessValue = this.equityEvaluator.GetReturnsEvaluation( strategyReturns ); ! // float fitnessValue = // this.getFitnessValue_withGoodFinal( strategyReturns ); ! // float fitnessValue = // BasicFunctions.GetSimpleAverage( strategyReturns ) / // ( Math.Pow( BasicFunctions.GetStdDev( strategyReturns ) , 1.3 ) ); *************** *** 227,241 **** WFLagWeightedPositions wFLagWeightedPositions ) { ! double[] drivingPositionsReturns = this.getFitnessValue_getLinearCombinationReturns( wFLagWeightedPositions.DrivingWeightedPositions ); ! double[] portfolioPositionsReturns = this.getFitnessValue_getLinearCombinationReturns( wFLagWeightedPositions.PortfolioWeightedPositions ); ! double[] strategyReturns = this.getFitnessValue_getStrategyReturn( drivingPositionsReturns , portfolioPositionsReturns ); ! double fitnessValue = this.getFitnessValue( strategyReturns ); ! return fitnessValue; } public double GetFitnessValue( Genome genome ) --- 227,241 ---- WFLagWeightedPositions wFLagWeightedPositions ) { ! float[] drivingPositionsReturns = this.getFitnessValue_getLinearCombinationReturns( wFLagWeightedPositions.DrivingWeightedPositions ); ! float[] portfolioPositionsReturns = this.getFitnessValue_getLinearCombinationReturns( wFLagWeightedPositions.PortfolioWeightedPositions ); ! float[] strategyReturns = this.getFitnessValue_getStrategyReturn( drivingPositionsReturns , portfolioPositionsReturns ); ! float fitnessValue = this.getFitnessValue( strategyReturns ); ! return (double)fitnessValue; } public double GetFitnessValue( Genome genome ) *************** *** 251,255 **** // genome contains a duplicate gene either for // driving positions or for portfolio positions ! //fitnessValue = double.MinValue; fitnessValue = -0.2; else --- 251,255 ---- // genome contains a duplicate gene either for // driving positions or for portfolio positions ! //fitnessValue = float.MinValue; fitnessValue = -0.2; else *************** *** 381,387 **** return tickerIndex; } ! private double getWeight( Genome genome , int genePosition ) { ! double weight = 1; if ( genome.GetGeneValue( genePosition ) < 0 ) // the position is short --- 381,387 ---- return tickerIndex; } ! private float getWeight( Genome genome , int genePosition ) { ! float weight = 1; if ( genome.GetGeneValue( genePosition ) < 0 ) // the position is short |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv28554/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio Modified Files: WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs Log Message: timeLineForOptimization is computed and used as a private member Index: WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs 24 Jun 2007 21:32:45 -0000 1.3 --- WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs 13 Jul 2007 10:13:06 -0000 1.4 *************** *** 24,30 **** --- 24,32 ---- using QuantProject.ADT; + using QuantProject.ADT.Histories; using QuantProject.ADT.Optimizing.Genetic; using QuantProject.Business.Strategies.EquityEvaluation; using QuantProject.Business.Timing; + using QuantProject.Data.DataTables; using QuantProject.Scripts.WalkForwardTesting.WalkForwardLag.WFLagDebugger; *************** *** 51,58 **** protected WFLagChosenPositions wFLagChosenPositions; ! // first in sample quote date for driving positions ! protected DateTime firstInSampleDateForDrivingPositions; ! // last in sample quote date for equity evaluation ! protected DateTime lastInSampleOptimizationDate; public int NumberOfDrivingPositions --- 53,60 ---- protected WFLagChosenPositions wFLagChosenPositions; ! // // first in sample quote date for driving positions ! // protected DateTime firstInSampleDateForDrivingPositions; ! // // last in sample quote date for equity evaluation ! // protected DateTime lastInSampleOptimizationDate; public int NumberOfDrivingPositions *************** *** 124,127 **** --- 126,139 ---- } #region setWeightedPositions_usingTheGeneticOptimizer + private History getTimeLineForOptimization( EndOfDayDateTime now ) + { + DateTime firstInSampleDateForDrivingPositions = + now.DateTime.AddDays( + -( this.NumberDaysForInSampleOptimization - 1 ) ); + DateTime lastInSampleOptimizationDate = + now.DateTime; + return Quotes.GetMarketDays( this.benchmark , + firstInSampleDateForDrivingPositions , lastInSampleOptimizationDate ); + } private void newGenerationEventHandler( object sender , NewGenerationEventArgs e ) *************** *** 154,162 **** EndOfDayDateTime now ) { ! this.firstInSampleDateForDrivingPositions = ! now.DateTime.AddDays( ! -( this.NumberDaysForInSampleOptimization - 1 ) ); ! this.lastInSampleOptimizationDate = ! now.DateTime; WFLagGenomeManagerForFixedPortfolioWithNormalDrivingAndPortfolio --- 166,171 ---- EndOfDayDateTime now ) { ! History timeLineForOptimization = ! this.getTimeLineForOptimization( now ); WFLagGenomeManagerForFixedPortfolioWithNormalDrivingAndPortfolio *************** *** 166,171 **** eligibleTickersForDrivingPositions.EligibleTickers , this.portfolioSignedTickers , ! this.firstInSampleDateForDrivingPositions , ! this.lastInSampleOptimizationDate , this.equityEvaluator , QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator ); --- 175,179 ---- eligibleTickersForDrivingPositions.EligibleTickers , this.portfolioSignedTickers , ! timeLineForOptimization , this.equityEvaluator , QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator ); |
|
From: Glauco S. <gla...@us...> - 2007-07-13 10:10:56
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv26268/b7_Scripts/WalkForwardTesting/WalkForwardLag Modified Files: WeightedPositions.cs Log Message: public float[] GetReturns( ReturnsManager returnsManager ) has been added public float GetReturn( int i , ReturnsManager returnsManager ) has been added Index: WeightedPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositions.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** WeightedPositions.cs 24 Jun 2007 21:31:05 -0000 1.4 --- WeightedPositions.cs 13 Jul 2007 10:10:45 -0000 1.5 *************** *** 28,31 **** --- 28,32 ---- using QuantProject.Business.Financial.Accounting; using QuantProject.Business.Strategies; + using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Timing; using QuantProject.Data.DataTables; *************** *** 204,229 **** #endregion #region GetCloseToClosePortfolioReturns - // private static double getCloseToCloseReturn( string ticker , - // SortedList datesForReturnComputation , int i ) - // { - // DateTime previousDate = (DateTime)datesForReturnComputation.GetByIndex( i ); - // DateTime currentDate = - // (DateTime)datesForReturnComputation.GetByIndex( i + 1 ); - // HistoricalAdjustedQuoteProvider historicalQuoteProvider = - // new HistoricalAdjustedQuoteProvider(); - // double previousQuote = historicalQuoteProvider.GetMarketValue( ticker , - // new EndOfDayDateTime( previousDate , EndOfDaySpecificTime.MarketClose ) ); - // double currentQuote = historicalQuoteProvider.GetMarketValue( ticker , - // new EndOfDayDateTime( currentDate , EndOfDaySpecificTime.MarketClose ) ); - // double closeToCloseReturn = currentQuote / previousQuote - 1.0; - // return closeToCloseReturn; - // } - // private static double getMultiplier( string signedTicker ) - // { - // double multiplier = 1.0; - // if ( IsShort( signedTicker ) ) - // multiplier = -multiplier; - // return multiplier; - // } private double getCloseToClosePortfolioReturn( SortedList datesForReturnComputation , int i ) --- 205,208 ---- *************** *** 323,355 **** string ticker = SignedTicker.GetTicker( signedTickers[ i ] ); tickerReturns[ i ] = Quotes.GetArrayOfCloseToCloseRatios( ! ticker , ref firstDate , lastDate , 1 ); } return tickerReturns; } ! private static double getStandardDeviation( float[] returnsForTicker ) ! { ! return BasicFunctions.GetStdDev( returnsForTicker ); ! } ! private static double[] getStandardDeviations( float[][] returnsForTickers ) { ! double[] standardDeviations = new double[ returnsForTickers.Length ]; ! for ( int i = 0 ; i < standardDeviations.Length ; i++ ) ! standardDeviations[ i ] = getStandardDeviation( returnsForTickers[ i ] ); ! return standardDeviations; } ! private static double[] getStandardDeviations( string[] signedTickers , ! DateTime firstDate , DateTime lastDate ) { ! float[][] returnsForTickers = getTickerCloseToCloseReturnsForSignedTickers( ! signedTickers , firstDate , lastDate ); ! return getStandardDeviations( returnsForTickers ); } private static double getNonNormalizedWeightsButBalancedForVolatility( ! double[] standardDeviations , double maxStandardDeviation , int i ) { return maxStandardDeviation / standardDeviations[ i ]; } private static double[] getNonNormalizedWeightsButBalancedForVolatility( ! double[] standardDeviations , double maxStandardDeviation ) { double[] nonNormalizedWeightsButBalancedForVolatility = --- 302,333 ---- string ticker = SignedTicker.GetTicker( signedTickers[ i ] ); tickerReturns[ i ] = Quotes.GetArrayOfCloseToCloseRatios( ! ticker , firstDate , lastDate ); } return tickerReturns; } ! private static float getTickerReturnsStandardDeviations( int tickerIndex , ! string[] signedTickers , ReturnsManager returnsManager ) { ! string ticker = SignedTicker.GetTicker( signedTickers[ tickerIndex ] ); ! return returnsManager.GetReturnsStandardDeviation( ticker ); } ! private static float[] getTickersReturnsStandardDeviations( ! string[] signedTickers , ReturnsManager returnsManager ) { ! float[] tickersReturnsStandardDeviations = ! new float[ signedTickers.Length ]; ! for ( int i = 0 ; i < signedTickers.Length ; i++ ) ! tickersReturnsStandardDeviations[ i ] = ! getTickerReturnsStandardDeviations( i , ! signedTickers , returnsManager ); ! return tickersReturnsStandardDeviations; } private static double getNonNormalizedWeightsButBalancedForVolatility( ! float[] standardDeviations , float maxStandardDeviation , int i ) { return maxStandardDeviation / standardDeviations[ i ]; } private static double[] getNonNormalizedWeightsButBalancedForVolatility( ! float[] standardDeviations , float maxStandardDeviation ) { double[] nonNormalizedWeightsButBalancedForVolatility = *************** *** 362,368 **** } private static double[] getNonNormalizedWeightsButBalancedForVolatility( ! double[] standardDeviations ) { ! double maxStandardDeviation = BasicFunctions.GetMax( standardDeviations ); return getNonNormalizedWeightsButBalancedForVolatility( standardDeviations , maxStandardDeviation ); --- 340,347 ---- } private static double[] getNonNormalizedWeightsButBalancedForVolatility( ! float[] standardDeviations ) { ! float maxStandardDeviation = ! (float)BasicFunctions.GetMax( standardDeviations ); return getNonNormalizedWeightsButBalancedForVolatility( standardDeviations , maxStandardDeviation ); *************** *** 376,382 **** /// <returns></returns> public static double[] GetBalancedWeights( ! string[] signedTickers , DateTime firstDate , DateTime lastDate ) { ! double[] standardDeviations = getStandardDeviations( signedTickers , firstDate , lastDate ); double[] nonNormalizedButBalancedWeights = getNonNormalizedWeightsButBalancedForVolatility( standardDeviations ); --- 355,363 ---- /// <returns></returns> public static double[] GetBalancedWeights( ! string[] signedTickers , ReturnsManager returnManager ) { ! float[] standardDeviations = ! getTickersReturnsStandardDeviations( signedTickers , ! returnManager ); double[] nonNormalizedButBalancedWeights = getNonNormalizedWeightsButBalancedForVolatility( standardDeviations ); *************** *** 386,389 **** --- 367,447 ---- } #endregion //GetBalancedWeights + #region GetReturn + private void getReturnCheckParameters( int i , + ReturnsManager returnsManager ) + { + if ( ( i < 0 ) || ( i > returnsManager.TimeLine.Count - 2 ) ) + throw new Exception( "i is larger than the number of returns" ); + } + private float getTickerReturn( string ticker , int i , + ReturnsManager returnsManager ) + { + return returnsManager.GetReturn( ticker , i ); + } + private float getReturnActually( WeightedPosition weightedPosition , + int i , ReturnsManager returnsManager ) + { + float tickerReturn = this.getTickerReturn( weightedPosition.Ticker , + i , returnsManager ); + return tickerReturn * Convert.ToSingle( weightedPosition.Weight ); + + + // int numberOfWeightedPositions = weightedPositions.Count; + // string[] tickers = this.getTickers( weightedPositions ); + // float[] multipliers = this.getMultipliers( weightedPositions ); + // // arrays of close to close returns, one for each signed ticker + // float[][] tickersReturns = + // this.wFLagCandidates.GetTickersReturns( tickers ); + // Aggiungi!!! weightedPositions.GetReturns( this.closeToCloseReturnsManager ) + // double[] linearCombinationReturns = + // new double[ tickersReturns[ 0 ].Length ]; + // for( int i = 0; i < linearCombinationReturns.Length ; i++ ) + // // computes linearCombinationReturns[ i ] + // { + // linearCombinationReturns[ i ] = 0; + // for ( int j=0 ; j < weightedPositions.Count ; j++ ) + // { + // double weightedPositionReturn = + // tickersReturns[ j ][ i ] * multipliers[ j ]; + // linearCombinationReturns[ i ] += weightedPositionReturn; + // } + // } + // return linearCombinationReturns; + } + private float getReturnActually( int i , ReturnsManager returnsManager ) + { + float linearCombinationReturn = 0; + foreach ( WeightedPosition weightedPosition in this.Values ) + linearCombinationReturn += this.getReturnActually( weightedPosition , + i , returnsManager ); + return linearCombinationReturn; + } + /// <summary> + /// returns the i_th return of the sum of the weighted positions + /// </summary> + /// <param name="i"></param> + /// <param name="returnsManager">used to efficiently store + /// ticker returns</param> + /// <returns></returns> + public float GetReturn( int i , ReturnsManager returnsManager ) + { + this.getReturnCheckParameters( i , returnsManager ); + return getReturnActually( i , returnsManager ); + } + #endregion GetReturn + /// <summary> + /// Computes an array of floats representing the returns + /// of all weighted position + /// </summary> + /// <param name="returnsManager"></param> + /// <returns></returns> + public float[] GetReturns( ReturnsManager returnsManager ) + { + float[] returns = new float[ + returnsManager.TimeLine.Count - 1 ]; + for ( int i = 0 ; i < returnsManager.TimeLine.Count ; i++ ) + returns[ i ] = this.GetReturn( i , returnsManager ); + return returns; + } } } |
|
From: Glauco S. <gla...@us...> - 2007-07-13 10:08:05
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataTables In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23694/b3_Data/DataTables Modified Files: Quotes.cs Log Message: public static History GetAdjustedCloseHistory( string ticker, DateTime firstQuoteDate, DateTime lastQuoteDate ) has been added. public static float[] GetArrayOfCloseToCloseRatios( string ticker , DateTime firstQuoteDate , DateTime lastQuoteDate ) has been added. GetMarketDays returns a History now (it returned a SortedList in the previous version). Index: Quotes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataTables/Quotes.cs,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** Quotes.cs 9 Apr 2007 17:48:47 -0000 1.33 --- Quotes.cs 13 Jul 2007 10:07:59 -0000 1.34 *************** *** 2,12 **** using System.Collections; using System.Data; using System.Text; using QuantProject.ADT; using QuantProject.ADT.Statistics; using QuantProject.ADT.Histories; using QuantProject.DataAccess; using QuantProject.DataAccess.Tables; - using System.Runtime.Serialization; namespace QuantProject.Data.DataTables --- 2,14 ---- using System.Collections; using System.Data; + using System.Runtime.Serialization; using System.Text; + using QuantProject.ADT; + using QuantProject.ADT.Collections; using QuantProject.ADT.Statistics; using QuantProject.ADT.Histories; using QuantProject.DataAccess; using QuantProject.DataAccess.Tables; namespace QuantProject.Data.DataTables *************** *** 720,732 **** } ! public static float[] GetArrayOfCloseToCloseRatios(string ticker, ! ref DateTime firstQuoteDate, ! DateTime lastQuoteDate, ! int numDaysBetweenEachClose) ! { ! return GetArrayOfCloseToCloseRatios(ticker, ref firstQuoteDate, lastQuoteDate, numDaysBetweenEachClose, ! 0); ! } ! public static float[] GetArrayOfAdjustedCloseQuotes(string ticker, DateTime firstQuoteDate, --- 722,734 ---- } ! public static float[] GetArrayOfCloseToCloseRatios(string ticker, ! ref DateTime firstQuoteDate, ! DateTime lastQuoteDate, ! int numDaysBetweenEachClose) ! { ! return GetArrayOfCloseToCloseRatios(ticker, ref firstQuoteDate, lastQuoteDate, numDaysBetweenEachClose, ! 0); ! } ! public static float[] GetArrayOfAdjustedCloseQuotes(string ticker, DateTime firstQuoteDate, *************** *** 736,739 **** --- 738,787 ---- return ExtendedDataTable.GetArrayOfFloatFromColumn(tickerQuotes,"quAdjustedClose"); } + #region GetAdjustedCloseHistory + private static History getAdjustedCloseHistory( Quotes tickerQuotes ) + { + History adjustedCloseHistory = new History(); + foreach ( DataRow dataRow in tickerQuotes.Rows ) + adjustedCloseHistory.Add( dataRow[ Quotes.Date ] , + dataRow[ Quotes.AdjustedClose ] ); + return adjustedCloseHistory; + } + /// <summary> + /// Returns the History of the adjusted close quotes, for the given ticker, + /// since the firstQuoteDate to the lastQuoteDate + /// </summary> + /// <param name="ticker"></param> + /// <param name="firstQuoteDate"></param> + /// <param name="lastQuoteDate"></param> + /// <returns></returns> + public static History GetAdjustedCloseHistory( string ticker, + DateTime firstQuoteDate, + DateTime lastQuoteDate ) + { + Quotes tickerQuotes = new Quotes( ticker , firstQuoteDate , lastQuoteDate); + return getAdjustedCloseHistory( tickerQuotes ); + } + #endregion GetAdjustedCloseHistory + #region GetArrayOfCloseToCloseRatios + /// <summary> + /// Returns the array of the adjusted close to adjusted close ratios, for + /// the given ticker, within the given period of time + /// </summary> + /// <param name="ticker"></param> + /// <param name="firstQuoteDate"></param> + /// <param name="lastQuoteDate"></param> + /// <returns></returns> + public static float[] GetArrayOfCloseToCloseRatios( + string ticker , + DateTime firstQuoteDate , + DateTime lastQuoteDate ) + { + float[] arrayOfAdjustedCloseQuotes = + GetArrayOfAdjustedCloseQuotes( ticker , firstQuoteDate , lastQuoteDate ); + float[] arrayOfCloseToCloseRatios = + FloatArrayManager.GetRatios( arrayOfAdjustedCloseQuotes ); + return arrayOfCloseToCloseRatios; + } + #endregion /// <summary> *************** *** 745,754 **** /// <param name="lastDate">end interval</param> /// <returns></returns> ! public static SortedList GetMarketDays( string ticker , DateTime firstDate , DateTime lastDate ) { Quotes quotes = new Quotes( ticker , firstDate , lastDate ); // DateTime[] marketDays = new DateTime[ quotes.Rows.Count ]; ! SortedList marketDays = new SortedList(); int i = 0; foreach ( DataRow dataRow in quotes.Rows ) --- 793,802 ---- /// <param name="lastDate">end interval</param> /// <returns></returns> ! public static History GetMarketDays( string ticker , DateTime firstDate , DateTime lastDate ) { Quotes quotes = new Quotes( ticker , firstDate , lastDate ); // DateTime[] marketDays = new DateTime[ quotes.Rows.Count ]; ! History marketDays = new History(); int i = 0; foreach ( DataRow dataRow in quotes.Rows ) |
|
From: Glauco S. <gla...@us...> - 2007-07-13 10:04:33
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EquityEvaluation In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv20497/b4_Business/a2_Strategies/EquityEvaluation Modified Files: IEquityEvaluator.cs Log Message: GetReturnsEvaluation( float[] returns ) returns a float now (it returned a double in previous version) Index: IEquityEvaluator.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EquityEvaluation/IEquityEvaluator.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IEquityEvaluator.cs 3 Nov 2006 16:27:03 -0000 1.2 --- IEquityEvaluator.cs 13 Jul 2007 10:04:29 -0000 1.3 *************** *** 30,34 **** public interface IEquityEvaluator { ! double GetReturnsEvaluation( double[] returns ); } } --- 30,34 ---- public interface IEquityEvaluator { ! float GetReturnsEvaluation( float[] returns ); } } |
|
From: Glauco S. <gla...@us...> - 2007-07-13 10:03:28
|
Update of /cvsroot/quantproject/QuantProject/b91_QuantProject In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv19437/b91_QuantProject Modified Files: b91_QuantProject.csproj Log Message: Automatic changes applied by VSNet Index: b91_QuantProject.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b91_QuantProject/b91_QuantProject.csproj,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** b91_QuantProject.csproj 15 Oct 2005 18:03:31 -0000 1.10 --- b91_QuantProject.csproj 13 Jul 2007 10:03:23 -0000 1.11 *************** *** 89,97 **** /> <Reference - Name = "b1_ADT" - Project = "{B8A01161-3698-4591-B1EF-90F5FC7D8DBA}" - Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" - /> - <Reference Name = "b5_Presentation" Project = "{D3DC9EA6-3B06-4255-B19A-5FC5B66A1402}" --- 89,92 ---- *************** *** 103,106 **** --- 98,106 ---- Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" /> + <Reference + Name = "b1_ADT" + Project = "{B8A01161-3698-4591-B1EF-90F5FC7D8DBA}" + Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" + /> </References> </Build> |
|
From: Glauco S. <gla...@us...> - 2007-07-13 10:02:58
|
Update of /cvsroot/quantproject/QuantProject/b4_Business In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv18790/b4_Business Modified Files: b4_Business.csproj Log Message: - a2_Strategies\returnsManagement\ReturnsManager.cs has been added - a2_Strategies\returnsManagement\CloseToCloseReturnsManager.cs has been added Index: b4_Business.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/b4_Business.csproj,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** b4_Business.csproj 11 Jun 2007 17:54:20 -0000 1.40 --- b4_Business.csproj 13 Jul 2007 10:02:55 -0000 1.41 *************** *** 638,641 **** --- 638,651 ---- /> <File + RelPath = "a2_Strategies\returnsManagement\CloseToCloseReturnsManager.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "a2_Strategies\returnsManagement\ReturnsManager.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "a3_Testing\BackTester.cs" SubType = "Code" |