quantproject-developers Mailing List for QuantProject (Page 19)
Brought to you by:
glauco_1
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(7) |
Nov
(103) |
Dec
(67) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(52) |
Feb
(9) |
Mar
(69) |
Apr
(53) |
May
(80) |
Jun
(23) |
Jul
(24) |
Aug
(112) |
Sep
(9) |
Oct
|
Nov
(58) |
Dec
(93) |
| 2005 |
Jan
(90) |
Feb
(93) |
Mar
(61) |
Apr
(56) |
May
(37) |
Jun
(61) |
Jul
(55) |
Aug
(68) |
Sep
(25) |
Oct
(46) |
Nov
(41) |
Dec
(37) |
| 2006 |
Jan
(33) |
Feb
(7) |
Mar
(19) |
Apr
(27) |
May
(73) |
Jun
(49) |
Jul
(83) |
Aug
(66) |
Sep
(45) |
Oct
(16) |
Nov
(15) |
Dec
(7) |
| 2007 |
Jan
(14) |
Feb
(33) |
Mar
|
Apr
(21) |
May
|
Jun
(34) |
Jul
(18) |
Aug
(100) |
Sep
(39) |
Oct
(55) |
Nov
(12) |
Dec
(2) |
| 2008 |
Jan
(120) |
Feb
(133) |
Mar
(129) |
Apr
(104) |
May
(42) |
Jun
(2) |
Jul
(52) |
Aug
(99) |
Sep
(134) |
Oct
|
Nov
(137) |
Dec
(48) |
| 2009 |
Jan
(48) |
Feb
(55) |
Mar
(61) |
Apr
(3) |
May
(2) |
Jun
(1) |
Jul
|
Aug
(51) |
Sep
|
Oct
(7) |
Nov
|
Dec
|
| 2010 |
Jan
(7) |
Feb
(1) |
Mar
(145) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(8) |
Dec
|
| 2011 |
Jan
(78) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(88) |
Sep
(6) |
Oct
(1) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
(1) |
Mar
|
Apr
(6) |
May
(5) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2013 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Marco M. <mi...@us...> - 2009-03-13 15:11:34
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv29956/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator Modified Files: PVOLogItem.cs PVOPositions.cs Log Message: A property in PVOPositions class has been renamed. Index: PVOPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVOPositions.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PVOPositions.cs 12 Jan 2009 18:11:01 -0000 1.5 --- PVOPositions.cs 13 Mar 2009 15:11:23 -0000 1.6 *************** *** 43,47 **** private double oversoldThreshold; private double overboughtThreshold; ! private int numDaysForOscillatingPeriod; private int generation; --- 43,47 ---- private double oversoldThreshold; private double overboughtThreshold; ! private int numOfDaysOrMinutesForOscillatingPeriod; private int generation; *************** *** 59,65 **** set{this.overboughtThreshold = value;} } ! public int NumDaysForOscillatingPeriod { ! get{return this.numDaysForOscillatingPeriod;} } --- 59,65 ---- set{this.overboughtThreshold = value;} } ! public int NumOfDaysOrMinutesForOscillatingPeriod { ! get{return this.numOfDaysOrMinutesForOscillatingPeriod;} } *************** *** 78,82 **** this.OversoldThreshold, this.overboughtThreshold, ! this.numDaysForOscillatingPeriod); } --- 78,82 ---- this.OversoldThreshold, this.overboughtThreshold, ! this.numOfDaysOrMinutesForOscillatingPeriod); } *************** *** 96,100 **** this.oversoldThreshold = oversoldThreshold; this.overboughtThreshold = overboughtThreshold; ! this.numDaysForOscillatingPeriod = numDaysForOscillatingPeriod; this.generation = -1; } --- 96,100 ---- this.oversoldThreshold = oversoldThreshold; this.overboughtThreshold = overboughtThreshold; ! this.numOfDaysOrMinutesForOscillatingPeriod = numDaysForOscillatingPeriod; this.generation = -1; } Index: PVOLogItem.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/PVOLogItem.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PVOLogItem.cs 12 Nov 2008 20:42:39 -0000 1.6 --- PVOLogItem.cs 13 Mar 2009 15:11:23 -0000 1.7 *************** *** 160,164 **** // objects that use it) int numDaysForOscillatingPeriodForChooser = ! ((PVOPositions)this.BestPVOPositionsInSample[0]).NumDaysForOscillatingPeriod; int numberOfPortfolioPositions = this.BestPVOPositionsInSample[0].WeightedPositions.Count; --- 160,164 ---- // objects that use it) int numDaysForOscillatingPeriodForChooser = ! ((PVOPositions)this.BestPVOPositionsInSample[0]).NumOfDaysOrMinutesForOscillatingPeriod; int numberOfPortfolioPositions = this.BestPVOPositionsInSample[0].WeightedPositions.Count; |
|
From: Marco M. <mi...@us...> - 2009-03-13 15:09:21
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv29370/b4_Business/a07_DataProviders Added Files: HistoricalBarInterpolatingProvider.cs Log Message: HistoricalBarInterpolatingProvider has been added: the interpolation method is very simple (it should be used only during in sample optimization). --- NEW FILE: HistoricalBarInterpolatingProvider.cs --- /* QuantProject - Quantitative Finance Library HistoricalBarInterpolatingProvider.cs Copyright (C) 2009 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.Timing; using QuantProject.Data.DataTables; using QuantProject.Data.DataProviders.Bars; using QuantProject.Data.DataProviders.Bars.Caching; namespace QuantProject.Business.DataProviders { /// <summary> /// Returns historical bars. When a bar is missing for a given time, /// an interpolated value is returned (just the average of previous market value /// and next market value). If only previous or next is available, the /// available value is returned /// </summary> [Serializable] public class HistoricalBarInterpolatingProvider : HistoricalMarketValueProvider { protected QuantProject.Data.DataProviders.Bars.HistoricalBarProvider historicalBarProvider; protected DataTable barsForDayForTicker; protected DateTime currentDate; protected string currentTicker; public HistoricalBarInterpolatingProvider( IBarCache barCache ) { this.historicalBarProvider = new QuantProject.Data.DataProviders.Bars.HistoricalBarProvider( barCache ); } #region oldImplementation getValuesOfPrevious Next // private double getMarketValue_getValueOfTheFirstNextMinuteAvailable(string ticker , // DateTime dateTime ) // { // double marketValue = double.MinValue; // DateTime nextDateTime = dateTime.AddMinutes(1); // DateTime closingTime = // Time.GetDateTimeFromMerge( dateTime, new Time(16,0,0) ); // while( nextDateTime.CompareTo(closingTime) <= 0 && // marketValue == double.MinValue ) // { // if( this.historicalBarProvider.WasExchanged(ticker, nextDateTime) ) // marketValue = this.historicalBarProvider.GetMarketValue(ticker, nextDateTime); // else // nextDateTime = nextDateTime.AddMinutes(1); // } // return marketValue; // } // // private double getMarketValue_getValueOfTheFirstPreviousMinuteAvailable(string ticker , // DateTime dateTime ) // { // double marketValue = double.MinValue; // DateTime previousDateTime = dateTime.AddMinutes(-1); // DateTime openingTime = // Time.GetDateTimeFromMerge( dateTime, new Time(9,30,0) ); // while( previousDateTime.CompareTo(openingTime) >= 0 && // marketValue == double.MinValue ) // { // if( this.historicalBarProvider.WasExchanged(ticker, previousDateTime) ) // marketValue = this.historicalBarProvider.GetMarketValue(ticker, previousDateTime); // else // previousDateTime = previousDateTime.AddMinutes(-1); // } // return marketValue; // } #endregion private double getInterpolatedValue_getValueOfTheFirstNextMinuteAvailable(string ticker , DateTime dateTime ) { double returnValue = double.MinValue; Bars barsFromNextMinuteOfDateTimeToClose = new Bars(ticker, dateTime, dateTime, new Time(dateTime).AddMinutes(1), new Time(16,0,0), 60); if( barsFromNextMinuteOfDateTimeToClose.Rows.Count > 0 ) returnValue = barsFromNextMinuteOfDateTimeToClose.GetFirstValidOpen(dateTime); return returnValue; } private double getInterpolatedValue_getValueOfTheFirstPreviousMinuteAvailable(string ticker , DateTime dateTime ) { double returnValue = double.MinValue; Bars barsFromOpenToPrecedingMinuteOfDateTime = new Bars(ticker, dateTime, dateTime, new Time(9,30,0), new Time(dateTime).AddMinutes(-1), 60); if( barsFromOpenToPrecedingMinuteOfDateTime.Rows.Count > 0 ) returnValue = barsFromOpenToPrecedingMinuteOfDateTime.GetFirstValidOpen(dateTime); return returnValue; } private double getInterpolatedValue_getInterpolatedOrThePreviousOrTheNextValue(double previousMarketValue, double nextMarketValue) { double returnValue = 0.0; if(previousMarketValue == double.MinValue && nextMarketValue != double.MinValue) returnValue = nextMarketValue; else if(previousMarketValue != double.MinValue && nextMarketValue == double.MinValue) returnValue = previousMarketValue; else if(previousMarketValue != double.MinValue && nextMarketValue != double.MinValue) returnValue = (previousMarketValue + nextMarketValue)/2; return returnValue; } protected virtual double getInterpolatedValue(string ticker , DateTime dateTime) { double previousMarketValue = this.getInterpolatedValue_getValueOfTheFirstPreviousMinuteAvailable(ticker , dateTime); double nextMarketValue = this.getInterpolatedValue_getValueOfTheFirstNextMinuteAvailable(ticker , dateTime); return this.getInterpolatedValue_getInterpolatedOrThePreviousOrTheNextValue(previousMarketValue, nextMarketValue); } public override double GetMarketValue( string ticker , DateTime dateTime ) { double marketValue = 0.0; if ( this.historicalBarProvider.WasExchanged( ticker , dateTime ) ) marketValue = this.historicalBarProvider.GetMarketValue( ticker , dateTime ); else { marketValue = this.getInterpolatedValue(ticker, dateTime); } return marketValue; } protected override string getDescription() { return "barInterpolatingProvider"; } private void wasExchanged_setBarsForDayForTickerIfNecessary(string ticker, DateTime dateTime) { if( this.currentTicker != ticker || this.currentDate != dateTime ) { this.currentDate = dateTime; this.currentTicker = ticker; this.barsForDayForTicker = QuantProject.DataAccess.Tables.Bars.GetTickerBars(ticker, Time.GetDateTimeFromMerge(dateTime, new Time(9,30,0)), Time.GetDateTimeFromMerge(dateTime, new Time(16,0,0)), 60 ); } } //it returns true just if there is a //bar for the day in dateTime public override bool WasExchanged(string ticker, DateTime dateTime) { bool returnValue = false; this.wasExchanged_setBarsForDayForTickerIfNecessary(ticker, dateTime); if( this.barsForDayForTicker.Rows.Count > 0 ) returnValue = true; return returnValue; } } } |
|
From: Marco M. <mi...@us...> - 2009-03-13 15:06:04
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv28571/b4_Business/a2_Strategies/returnsManagement/time Modified Files: ReturnIntervals.cs Log Message: no message Index: ReturnIntervals.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time/ReturnIntervals.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ReturnIntervals.cs 28 Feb 2009 18:43:16 -0000 1.10 --- ReturnIntervals.cs 13 Mar 2009 15:05:42 -0000 1.11 *************** *** 153,157 **** firstDateTime , lastDateTime, benchmark, intervalLength ); } ! /// <summary> /// Use this constructor if you want to create an empty --- 153,157 ---- firstDateTime , lastDateTime, benchmark, intervalLength ); } ! /// <summary> /// Use this constructor if you want to create an empty |
|
From: Marco M. <mi...@us...> - 2009-03-13 15:04:42
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv28257/b2_DataAccess/Tables Modified Files: Bars.cs Log Message: Some bugs have been fixed Index: Bars.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables/Bars.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Bars.cs 8 Feb 2009 16:43:34 -0000 1.9 --- Bars.cs 13 Mar 2009 15:04:23 -0000 1.10 *************** *** 268,276 **** DateTime lastBarDateTime, int intervalFrameInSeconds) { ! string sql = "select * from bars " + "where " + Bars.TickerFieldName + "='" + ticker + "' and " + Bars.IntervalFrameInSeconds + "='" + intervalFrameInSeconds + "' " + ! "and " + Bars.DateTimeForOpen + " between " + SQLBuilder.GetDateConstant(firstBarDateTime) + " " + ! "and " + SQLBuilder.GetDateConstant(lastBarDateTime) + " " + "order by " + Bars.DateTimeForOpen; return SqlExecutor.GetDataTable( sql ); --- 268,278 ---- DateTime lastBarDateTime, int intervalFrameInSeconds) { ! string sql = "select " + ! Bars.Open + "," + Bars.Low + "," + Bars.High + "," + Bars.Close + ! " from bars " + "where " + Bars.TickerFieldName + "='" + ticker + "' and " + Bars.IntervalFrameInSeconds + "='" + intervalFrameInSeconds + "' " + ! "and " + Bars.DateTimeForOpen + " between " + SQLBuilder.GetDateTimeConstant(firstBarDateTime) + " " + ! "and " + SQLBuilder.GetDateTimeConstant(lastBarDateTime) + " " + "order by " + Bars.DateTimeForOpen; return SqlExecutor.GetDataTable( sql ); *************** *** 382,386 **** { string sql = ! "select baDateTimeForOpen from bars " + "where (baTicker='" + ticker + "') and " + "(baInterval=" + intervalFrameInSeconds + ") and" + --- 384,388 ---- { string sql = ! "select baDateTimeForOpen, baOpen, baHigh, baLow, baClose from bars " + "where (baTicker='" + ticker + "') and " + "(baInterval=" + intervalFrameInSeconds + ") and" + |
|
From: Marco M. <mi...@us...> - 2009-03-13 15:04:40
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataTables In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv28257/b3_Data/DataTables Modified Files: Bars.cs Log Message: Some bugs have been fixed Index: Bars.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataTables/Bars.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Bars.cs 7 Jan 2009 23:23:54 -0000 1.6 --- Bars.cs 13 Mar 2009 15:04:23 -0000 1.7 *************** *** 211,214 **** --- 211,256 ---- } + /// <summary> + /// returns the days when the ticker was exchanged for at least + /// the given number of bars of the given interval in seconds, + /// within the given date time interval + /// </summary> + /// <param name="ticker"></param> + /// <param name="firstDateTime">begin interval</param> + /// <param name="lastDateTime">end interval</param> + /// <param name="intervalFrameInSeconds">interval frame in seconds for the ticker's bars</param> + /// <param name="minimumNumberOfBarsForEachMarketDay">a day is returned only if + /// the day's bars are equal or greater than the minimumNumberOfBars</param> + /// <returns>History of days with minimumNumberOfBars in each</returns> + public static History GetMarketDays( string ticker , + DateTime firstDateTime , + DateTime lastDateTime, + int intervalFrameInSeconds , + int minimumNumberOfBarsForEachMarketDay ) + + { + History marketDaysToBeReturned = new History(); + DateTime marketDayToCheck = + Time.GetDateTimeFromMerge( firstDateTime, new Time(9,30,0) ); + DataTable barsForMarketDayToBeReturned; + while( marketDayToCheck.CompareTo(lastDateTime) <= 0 ) + { + barsForMarketDayToBeReturned = + QuantProject.DataAccess.Tables.Bars.GetTickerBars(ticker, marketDayToCheck, + Time.GetDateTimeFromMerge(marketDayToCheck, new Time(16,0,0)), + intervalFrameInSeconds); + if (barsForMarketDayToBeReturned.Rows.Count >= minimumNumberOfBarsForEachMarketDay) + { + DateTime dayToAdd = + Time.GetDateTimeFromMerge(marketDayToCheck, new Time(0,0,0)); + marketDaysToBeReturned.Add( dayToAdd, dayToAdd ); + } + marketDayToCheck = + marketDayToCheck.AddDays(1); + } + return marketDaysToBeReturned; + } + + #region GetMarketDateTimes *************** *** 488,492 **** { this.history = new History(); ! this.history.Import( this , Bars.DateTimeForOpen , Bars.Close ); } } --- 530,534 ---- { this.history = new History(); ! this.history.Import( this , Bars.DateTimeForOpen , Bars.DateTimeForOpen ); } } *************** *** 599,603 **** return this.GetBarDateTimeOrFollowing(dateTime); } ! else { return this.GetBarDateTimeOrPreceding(dateTime); --- 641,645 ---- return this.GetBarDateTimeOrFollowing(dateTime); } ! else//dateTime > endDateTime { return this.GetBarDateTimeOrPreceding(dateTime); *************** *** 648,652 **** /// </summary> /// <returns></returns> ! public float GetFirstValidOpen(DateTime dateTime ) { object[] keys = new object[1]; --- 690,694 ---- /// </summary> /// <returns></returns> ! public double GetFirstValidOpen(DateTime dateTime ) { object[] keys = new object[1]; *************** *** 655,659 **** if(foundRow==null) throw new Exception("No bar for such a dateTime!"); ! return (float)foundRow[Bars.Open]; } } --- 697,701 ---- if(foundRow==null) throw new Exception("No bar for such a dateTime!"); ! return (double)foundRow[Bars.Open]; } } |
|
From: Marco M. <mi...@us...> - 2009-03-13 15:03:02
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataProviders/Bars/Caching In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv27063/b3_Data/DataProviders/Bars/Caching Modified Files: SimpleBarCache.cs Log Message: no message Index: SimpleBarCache.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataProviders/Bars/Caching/SimpleBarCache.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SimpleBarCache.cs 28 Feb 2009 18:44:02 -0000 1.4 --- SimpleBarCache.cs 13 Mar 2009 15:02:42 -0000 1.5 *************** *** 23,26 **** --- 23,27 ---- using System; + using QuantProject.ADT; using QuantProject.DataAccess; *************** *** 28,40 **** { /// <summary> ! /// It isn't really a cache: it just access to database /// </summary> public class SimpleBarCache : IBarCache { private int intervalFrameInSeconds; public SimpleBarCache(int intervalFrameInSeconds) { this.intervalFrameInSeconds = intervalFrameInSeconds; } --- 29,49 ---- { /// <summary> ! /// It isn't really a cache: it just access the database /// </summary> public class SimpleBarCache : IBarCache { private int intervalFrameInSeconds; + private BarComponent barComponent; + + public SimpleBarCache(int intervalFrameInSeconds, BarComponent barComponent) + { + this.intervalFrameInSeconds = intervalFrameInSeconds; + this.barComponent = barComponent; + } public SimpleBarCache(int intervalFrameInSeconds) { this.intervalFrameInSeconds = intervalFrameInSeconds; + this.barComponent = BarComponent.Open; } *************** *** 51,56 **** try { ! returnValue = ! QuantProject.DataAccess.Tables.Bars.GetOpen( ticker , dateTime , this.intervalFrameInSeconds ); } catch( EmptyQueryException ex ) --- 60,82 ---- try { ! switch (this.barComponent) ! { ! case BarComponent.Open : ! returnValue = QuantProject.DataAccess.Tables.Bars.GetOpen( ticker , dateTime , this.intervalFrameInSeconds ); ! break; ! case BarComponent.Close : ! returnValue = QuantProject.DataAccess.Tables.Bars.GetClose( ticker , dateTime , this.intervalFrameInSeconds ); ! break; ! case BarComponent.High : ! returnValue = QuantProject.DataAccess.Tables.Bars.GetHigh( ticker , dateTime , this.intervalFrameInSeconds ); ! break; ! case BarComponent.Low : ! returnValue = QuantProject.DataAccess.Tables.Bars.GetLow( ticker , dateTime , this.intervalFrameInSeconds ); ! break; ! //this line should never be reached! ! default: ! returnValue = QuantProject.DataAccess.Tables.Bars.GetOpen( ticker , dateTime , this.intervalFrameInSeconds ); ! break; ! } } catch( EmptyQueryException ex ) |
|
From: Glauco S. <gla...@us...> - 2009-03-10 23:17:53
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17170/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables Modified Files: Transactions.cs Log Message: Bug fixed: the column "TransactionType" has been added back to the DataTable (the previous revision introduced the bug, that lead to an exception thrown when the Report was built) Index: Transactions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables/Transactions.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Transactions.cs 9 Mar 2009 17:46:50 -0000 1.6 --- Transactions.cs 10 Mar 2009 23:17:45 -0000 1.7 *************** *** 30,33 **** --- 30,34 ---- Transactions.FieldNameForDateTime , Type.GetType( "System.DateTime" ) ); // transactionsDataTable.Columns.Add( "BarComponent" , Type.GetType( "System.String" ) ); + transactionsDataTable.Columns.Add( "TransactionType" , Type.GetType( "System.String" ) ); transactionsDataTable.Columns.Add( Transactions.FieldNameForTicker , Type.GetType( "System.String" ) ); |
|
From: Glauco S. <gla...@us...> - 2009-03-09 22:48:30
|
Update of /cvsroot/quantproject/QuantProject/b5_Presentation In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv21140/b5_Presentation Modified Files: HistoriesViewer.cs HistoriesViewer.Designer.cs Log Message: - the form title is a parameter, now - the chart is fill-docked to the form, now - the form has been resized Index: HistoriesViewer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b5_Presentation/HistoriesViewer.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HistoriesViewer.cs 28 Feb 2009 18:18:11 -0000 1.1 --- HistoriesViewer.cs 9 Mar 2009 22:48:25 -0000 1.2 *************** *** 40,44 **** private Chart chart; ! public HistoriesViewer() { // --- 40,44 ---- private Chart chart; ! public HistoriesViewer( string formTitle ) { // *************** *** 47,50 **** --- 47,51 ---- InitializeComponent(); + this.Text = formTitle; this.addChart(); } *************** *** 53,56 **** --- 54,58 ---- { this.chart = new Chart(); + this.chart.Dock = DockStyle.Fill; this.Controls.Add( chart ); } *************** *** 60,105 **** this.chart.Add( historyToBePlotted , color ); } - - // #region buildTheForm - // - // private void addChart() - // { - // Chart chart = new Chart(); - // this.Controls.Add( chart ); - // } - // - // #region populateChart - // - // #region addChart - // - // #region getHistoryToBePlotted - // private History getHistoryToBePlotted( WeightedPosition weightedPosition ) - // { - // - // } - // #endregion getHistoryToBePlotted - // - // private void addHistory( WeightedPosition weightedPosition ) - // { - // History historyToBePlotted = - // this.getHistoryToBePlotted( weightedPosition ); - // this.addHistory( historyToBePlotted ); - // } - // #endregion addChart - // - // private void populateChart() - // { - // foreach ( WeightedPosition weightedPosition in - // this.pairsTradingTestingPositions.WeightedPositions ) - // this.addHistory( weightedPosition ); - // } - // #endregion populateChart - // - // private void buildTheForm() - // { - // this.addChart(); - // this.populateChart(); - // } - // #endregion buildTheForm } } --- 62,65 ---- Index: HistoriesViewer.Designer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b5_Presentation/HistoriesViewer.Designer.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HistoriesViewer.Designer.cs 28 Feb 2009 18:18:11 -0000 1.1 --- HistoriesViewer.Designer.cs 9 Mar 2009 22:48:26 -0000 1.2 *************** *** 1,3 **** ! /* QuantProject - Quantitative Finance Library --- 1,3 ---- ! /* QuantProject - Quantitative Finance Library *************** *** 53,62 **** this.SuspendLayout(); // ! // PairsTradingStudio // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; ! this.ClientSize = new System.Drawing.Size(787, 403); ! this.Name = "PairsTradingStudio"; this.Text = "PairsTradingVisualForm"; this.ResumeLayout(false); --- 53,62 ---- this.SuspendLayout(); // ! // HistoriesViewer // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; ! this.ClientSize = new System.Drawing.Size(333, 309); ! this.Name = "HistoriesViewer"; this.Text = "PairsTradingVisualForm"; this.ResumeLayout(false); |
|
From: Glauco S. <gla...@us...> - 2009-03-09 22:44:46
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18380/b7_Scripts Modified Files: Scripts_SD.csproj Log Message: - WalkForwardTesting\PairsTrading\Logging\PairsViewer.cs has been moved to WalkForwardTesting\PairsTrading\Logging\PairsViewer\PairsViewer.cs - WalkForwardTesting\PairsTrading\Logging\PairsViewer\ReturnsComputer.cs has been added Index: Scripts_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/Scripts_SD.csproj,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** Scripts_SD.csproj 7 Mar 2009 04:22:06 -0000 1.37 --- Scripts_SD.csproj 9 Mar 2009 22:44:33 -0000 1.38 *************** *** 127,134 **** <Compile Include="WalkForwardTesting\PairsTrading\Logging\PairsTradingLogItem.cs" /> <Compile Include="WalkForwardTesting\PairsTrading\Logging\PairsTradingSerializedReportViewer.cs" /> ! <Compile Include="WalkForwardTesting\PairsTrading\Logging\PairsViewer.cs" /> ! <Compile Include="WalkForwardTesting\PairsTrading\Logging\PairsViewer.Designer.cs"> <DependentUpon>PairsViewer.cs</DependentUpon> </Compile> <Compile Include="WalkForwardTesting\PairsTrading\Logging\TesterForPairsTradingTestingPositionsEndOfDayInSample.cs" /> <Compile Include="WalkForwardTesting\PairsTrading\Logging\TesterForPairsTradingTestingPositions.cs" /> --- 127,135 ---- <Compile Include="WalkForwardTesting\PairsTrading\Logging\PairsTradingLogItem.cs" /> <Compile Include="WalkForwardTesting\PairsTrading\Logging\PairsTradingSerializedReportViewer.cs" /> ! <Compile Include="WalkForwardTesting\PairsTrading\Logging\PairsViewer\PairsViewer.cs" /> ! <Compile Include="WalkForwardTesting\PairsTrading\Logging\PairsViewer\PairsViewer.Designer.cs"> <DependentUpon>PairsViewer.cs</DependentUpon> </Compile> + <Compile Include="WalkForwardTesting\PairsTrading\Logging\PairsViewer\ReturnsComputer.cs" /> <Compile Include="WalkForwardTesting\PairsTrading\Logging\TesterForPairsTradingTestingPositionsEndOfDayInSample.cs" /> <Compile Include="WalkForwardTesting\PairsTrading\Logging\TesterForPairsTradingTestingPositions.cs" /> *************** *** 313,316 **** --- 314,318 ---- <Folder Include="WalkForwardTesting\PairsTrading\Logging" /> <Folder Include="WalkForwardTesting\PairsTrading\ExitStrategies" /> + <Folder Include="WalkForwardTesting\PairsTrading\Logging\PairsViewer" /> <Folder Include="WalkForwardTesting\PairsTrading\OutOfSampleChoosers" /> <Folder Include="WalkForwardTesting\PairsTrading\OutOfSampleChoosers\InefficiencyCorrectionDetecion" /> |
|
From: Glauco S. <gla...@us...> - 2009-03-09 22:43:43
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging/PairsViewer In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17668/PairsViewer Added Files: ReturnsComputer.cs Log Message: Computes returns to be shown by the PairsViewer --- NEW FILE: ReturnsComputer.cs --- /* QuantProject - Quantitative Finance Library ReturnsComputer.cs Copyright (C) 2009 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.ADT.Histories; using QuantProject.Business.DataProviders; using QuantProject.Business.Strategies; using QuantProject.Business.Timing; namespace QuantProject.Scripts.WalkForwardTesting.PairsTrading { /// <summary> /// Computes returns to be shown by the PairsViewer /// </summary> public class ReturnsComputer { private HistoricalMarketValueProvider historicalMarketValueProvider; private DateTime lastComputedIntervalBeginDateTime; private string currentTicker; private double marketValueAtTheIntervalBegin; public ReturnsComputer( HistoricalMarketValueProvider historicalMarketValueProvider ) { this.historicalMarketValueProvider = historicalMarketValueProvider; this.lastComputedIntervalBeginDateTime = DateTime.MinValue; this.currentTicker = "undefinedValue_itHasToBeInitialized"; } #region getReturns #region addReturnsToHistory #region addReturnToHistory #region getMarketValueAtTheIntervalBegin #region updateCacheValuesForIntervalBeginIfTheCase #region updateCacheValueForIntervalBeginDateTime protected virtual DateTime getIntervalBeginDateTime( DateTime dateTime ) { DateTime yesterday = dateTime.AddDays( -1 ); DateTime yesterdayAtClose = HistoricalEndOfDayTimer.GetMarketClose( yesterday ); DateTime intervalBeginDateTime = yesterdayAtClose.AddMinutes( -1 ); return intervalBeginDateTime; } private bool updateLastComputedIntervalBeginDateTime( DateTime dateTime ) { DateTime intervalBeginDateTime = this.getIntervalBeginDateTime( dateTime ); bool isUpdated = ( intervalBeginDateTime != this.lastComputedIntervalBeginDateTime ); if ( isUpdated ) // the interval begin has changed since the last return calculation this.lastComputedIntervalBeginDateTime = intervalBeginDateTime; return isUpdated; } #endregion updateCacheValueForIntervalBeginDateTime private bool updateCurrentTicker( WeightedPosition weightedPosition ) { bool isUpdated = ( this.currentTicker != weightedPosition.Ticker ); if ( isUpdated ) // the ticker has changed since the last return calculation this.currentTicker = weightedPosition.Ticker; return isUpdated; } private void updateCacheValuesForIntervalBeginIfTheCase( DateTime dateTime , WeightedPosition weightedPosition ) { bool isIntervalBeginDateTimeUpdated = this.updateLastComputedIntervalBeginDateTime( dateTime ); bool isCurrentTickerUpdated = this.updateCurrentTicker( weightedPosition ); if ( isIntervalBeginDateTimeUpdated || isCurrentTickerUpdated ) // either the interval begin or the ticker has been updated this.marketValueAtTheIntervalBegin = this.historicalMarketValueProvider.GetMarketValue( this.currentTicker , this.lastComputedIntervalBeginDateTime ); } #endregion updateCacheValuesForIntervalBeginIfTheCase protected virtual double getMarketValueAtTheIntervalBegin( DateTime dateTime , WeightedPosition weightedPosition ) { this.updateCacheValuesForIntervalBeginIfTheCase( dateTime , weightedPosition ); return this.marketValueAtTheIntervalBegin; } #endregion getMarketValueAtTheIntervalBegin private void addReturnToHistory( DateTime dateTime , WeightedPosition weightedPosition , History marketValuesForTheWeightedPosition , History returns ) { double marketValueAtTheIntervalBegin = this.getMarketValueAtTheIntervalBegin( dateTime , weightedPosition ); double marketValueAtTheIntervalEnd = (double)marketValuesForTheWeightedPosition[ dateTime ]; double currentReturn = marketValueAtTheIntervalEnd / marketValueAtTheIntervalBegin - 1; returns.Add( dateTime , currentReturn ); } #endregion addReturnToHistory private void addReturnsToHistory( WeightedPosition weightedPosition , History marketValuesForTheWeightedPosition , History returns ) { foreach ( DateTime dateTime in marketValuesForTheWeightedPosition.Keys ) this.addReturnToHistory( dateTime , weightedPosition , marketValuesForTheWeightedPosition , returns ); } #endregion addReturnsToHistory /// <summary> /// returns the history of returns /// </summary> /// <param name="weightedPosition"></param> /// <param name="marketValuesForTheWeightedPosition"></param> /// <returns></returns> public History GetReturns( WeightedPosition weightedPosition , History marketValuesForTheWeightedPosition ) { History returns = new History(); this.addReturnsToHistory( weightedPosition , marketValuesForTheWeightedPosition , returns ); return returns; } #endregion getReturns } } |
|
From: Glauco S. <gla...@us...> - 2009-03-09 22:43:12
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging/PairsViewer In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17404/PairsViewer Added Files: PairsViewer.cs PairsViewer.Designer.cs Log Message: WalkForwardTesting\PairsTrading\Logging\PairsViewer.cs has been moved to WalkForwardTesting\PairsTrading\Logging\PairsViewer\PairsViewer.cs --- NEW FILE: PairsViewer.Designer.cs --- (This appears to be a binary file; contents omitted.) --- NEW FILE: PairsViewer.cs --- /* QuantProject - Quantitative Finance Library PairsViewer.cs Copyright (C) 2009 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Drawing; using System.Windows.Forms; using QuantProject.ADT.Histories; using QuantProject.Business.DataProviders; using QuantProject.Business.Strategies; using QuantProject.Business.Timing; using QuantProject.Presentation; namespace QuantProject.Scripts.WalkForwardTesting.PairsTrading { /// <summary> /// Form used to display two pairs trading candidates /// </summary> public partial class PairsViewer : Form { private HistoricalMarketValueProvider historicalMarketValueProvider; private WeightedPosition firstWeightedPosition; private WeightedPosition secondWeightedPosition; public PairsViewer( HistoricalMarketValueProvider historicalMarketValueProvider , WeightedPosition firstWeightedPosition , WeightedPosition secondWeightedPosition , DateTime dateTime ) { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); this.historicalMarketValueProvider = historicalMarketValueProvider; this.firstWeightedPosition = firstWeightedPosition; this.secondWeightedPosition = secondWeightedPosition; this.dateTimePickerForFirstDateTime.Value = this.initializeFirstDateTime( dateTime ); this.textBoxGreenTicker.Text = firstWeightedPosition.Ticker; this.textBoxRedTicker.Text = secondWeightedPosition.Ticker; this.dateTimePickerForLastDateTime.Value = this.initializeLastDateTime(); } private DateTime initializeFirstDateTime( DateTime dateTime ) { DateTime firstDateTime = dateTime.AddMinutes( -10 ); // HistoricalEndOfDayTimer.GetMarketOpen( // this.dateTimePicker.Value.AddDays( 1 ) ); return firstDateTime; } private DateTime initializeLastDateTime() { DateTime firstDateTime = this.dateTimePickerForFirstDateTime.Value; DateTime lastDateTime = HistoricalEndOfDayTimer.GetMarketClose( firstDateTime ); return lastDateTime; } #region ButtonShowClick #region getHistory #region addItemsToHistory private void addItemToHistory( WeightedPosition weightedPosition , DateTime dateTime , History history ) { try { double marketValue = this.historicalMarketValueProvider.GetMarketValue( weightedPosition.Ticker , dateTime ); history.Add( dateTime , marketValue ); } catch( TickerNotExchangedException tickerNotExchangedException ) { string toAvoidWarning = tickerNotExchangedException.Message; } } private void addItemsToHistory( WeightedPosition weightedPosition , History history ) { DateTime currentDateTime = this.dateTimePickerForFirstDateTime.Value; DateTime lastDateTime = this.dateTimePickerForLastDateTime.Value; while ( currentDateTime <= lastDateTime ) { this.addItemToHistory( weightedPosition , currentDateTime , history ); currentDateTime = currentDateTime.AddMinutes( 1 ); } } #endregion addItemsToHistory private History getHistory( WeightedPosition weightedPosition ) { History history = new History(); this.addItemsToHistory( weightedPosition , history ); return history; } #endregion getHistory #region showHistoriesPlots private HistoriesViewer showHistoriesPlots( History firstHistory , History secondHistory , string formTitle , int xPosition , int yPosition ) { HistoriesViewer historiesViewer = new HistoriesViewer( formTitle ); historiesViewer.StartPosition = FormStartPosition.Manual; historiesViewer.Location = new Point( xPosition , yPosition ); historiesViewer.Add( firstHistory , Color.Green ); historiesViewer.Add( secondHistory , Color.Red ); historiesViewer.Show(); return historiesViewer; } private void showHistoriesPlots( History firstTickerMarketValues , History secondTickerMarketValues , History firstTickerReturns , History secondTickerReturns ) { HistoriesViewer historiesViewer = this.showHistoriesPlots( firstTickerMarketValues , secondTickerMarketValues , "Market Values ($)" , this.Location.X + this.Size.Width , this.Location.Y ); this.showHistoriesPlots( firstTickerReturns , secondTickerReturns , "Returns" , historiesViewer.Location.X , historiesViewer.Location.Y + historiesViewer.Size.Height ); } #endregion showHistoriesPlots void ButtonShowClick(object sender, EventArgs e) { History firstTickerMarketValues = this.getHistory( this.firstWeightedPosition ); History secondTickerMarketValues = this.getHistory( this.secondWeightedPosition ); ReturnsComputer returnsComputer = new ReturnsComputer( this.historicalMarketValueProvider ); History firstTickerReturns = returnsComputer.GetReturns( this.firstWeightedPosition , firstTickerMarketValues ); History secondTickerReturns = returnsComputer.GetReturns( this.secondWeightedPosition , secondTickerMarketValues ); this.showHistoriesPlots( firstTickerMarketValues , secondTickerMarketValues , firstTickerReturns , secondTickerReturns ); } #endregion ButtonShowClick } } |
|
From: Glauco S. <gla...@us...> - 2009-03-09 22:41:39
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16166 Removed Files: PairsViewer.cs PairsViewer.Designer.cs Log Message: WalkForwardTesting\PairsTrading\Logging\PairsViewer.cs has been moved to WalkForwardTesting\PairsTrading\Logging\PairsViewer\PairsViewer.cs --- PairsViewer.Designer.cs DELETED --- --- PairsViewer.cs DELETED --- |
|
From: Glauco S. <gla...@us...> - 2009-03-09 22:39:26
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging/PairsViewer In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14405/PairsViewer Log Message: Directory /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging/PairsViewer added to the repository |
|
From: Glauco S. <gla...@us...> - 2009-03-09 17:47:08
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv8739/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables Modified Files: Transactions.cs Log Message: A recently introduced bug has been fixed: the "InstrumentKey" field was added twice to the DataTable Index: Transactions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables/Transactions.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Transactions.cs 7 Mar 2009 04:42:05 -0000 1.5 --- Transactions.cs 9 Mar 2009 17:46:50 -0000 1.6 *************** *** 32,36 **** transactionsDataTable.Columns.Add( Transactions.FieldNameForTicker , Type.GetType( "System.String" ) ); ! transactionsDataTable.Columns.Add( "InstrumentKey" , Type.GetType( "System.String" ) ); transactionsDataTable.Columns.Add( "Quantity" , Type.GetType( "System.Int32" ) ); transactionsDataTable.Columns.Add( "Price" , Type.GetType( "System.Double" ) ); --- 32,36 ---- transactionsDataTable.Columns.Add( Transactions.FieldNameForTicker , Type.GetType( "System.String" ) ); ! // transactionsDataTable.Columns.Add( "InstrumentKey" , Type.GetType( "System.String" ) ); transactionsDataTable.Columns.Add( "Quantity" , Type.GetType( "System.Int32" ) ); transactionsDataTable.Columns.Add( "Price" , Type.GetType( "System.Double" ) ); |
|
From: Glauco S. <gla...@us...> - 2009-03-09 17:46:21
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv5368/b7_Scripts/WalkForwardTesting/PairsTrading/Logging Modified Files: PairsViewer.Designer.cs Log Message: - a DateTimePicker has been added to chose the final date time for the chart - tickers are now displayed, each with its own line colour Index: PairsViewer.Designer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging/PairsViewer.Designer.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PairsViewer.Designer.cs 7 Mar 2009 04:20:46 -0000 1.1 --- PairsViewer.Designer.cs 9 Mar 2009 17:45:51 -0000 1.2 *************** *** 52,72 **** private void InitializeComponent() { ! this.dateTimePicker = new System.Windows.Forms.DateTimePicker(); this.buttonShow = new System.Windows.Forms.Button(); this.SuspendLayout(); // ! // dateTimePicker // ! this.dateTimePicker.CustomFormat = "yyyy-MM-dd HH:mm"; ! this.dateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom; ! this.dateTimePicker.Location = new System.Drawing.Point(24, 47); ! this.dateTimePicker.Name = "dateTimePicker"; ! this.dateTimePicker.ShowUpDown = true; ! this.dateTimePicker.Size = new System.Drawing.Size(256, 20); ! this.dateTimePicker.TabIndex = 0; // // buttonShow // ! this.buttonShow.Location = new System.Drawing.Point(104, 131); this.buttonShow.Name = "buttonShow"; this.buttonShow.Size = new System.Drawing.Size(75, 23); --- 52,79 ---- private void InitializeComponent() { ! this.dateTimePickerForFirstDateTime = new System.Windows.Forms.DateTimePicker(); this.buttonShow = new System.Windows.Forms.Button(); + this.labelFirstDateTime = new System.Windows.Forms.Label(); + this.labelLastDateTime = new System.Windows.Forms.Label(); + this.dateTimePickerForLastDateTime = new System.Windows.Forms.DateTimePicker(); + this.panelGreenTicker = new System.Windows.Forms.Panel(); + this.textBoxGreenTicker = new System.Windows.Forms.TextBox(); + this.textBoxRedTicker = new System.Windows.Forms.TextBox(); + this.panelRedTicker = new System.Windows.Forms.Panel(); this.SuspendLayout(); // ! // dateTimePickerForFirstDateTime // ! this.dateTimePickerForFirstDateTime.CustomFormat = "yyyy-MM-dd HH:mm"; ! this.dateTimePickerForFirstDateTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom; ! this.dateTimePickerForFirstDateTime.Location = new System.Drawing.Point(137, 27); ! this.dateTimePickerForFirstDateTime.Name = "dateTimePickerForFirstDateTime"; ! this.dateTimePickerForFirstDateTime.ShowUpDown = true; ! this.dateTimePickerForFirstDateTime.Size = new System.Drawing.Size(143, 20); ! this.dateTimePickerForFirstDateTime.TabIndex = 0; // // buttonShow // ! this.buttonShow.Location = new System.Drawing.Point(102, 197); this.buttonShow.Name = "buttonShow"; this.buttonShow.Size = new System.Drawing.Size(75, 23); *************** *** 76,79 **** --- 83,144 ---- this.buttonShow.Click += new System.EventHandler(this.ButtonShowClick); // + // labelFirstDateTime + // + this.labelFirstDateTime.Location = new System.Drawing.Point(31, 27); + this.labelFirstDateTime.Name = "labelFirstDateTime"; + this.labelFirstDateTime.Size = new System.Drawing.Size(100, 23); + this.labelFirstDateTime.TabIndex = 2; + this.labelFirstDateTime.Text = "First Date Time:"; + this.labelFirstDateTime.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // labelLastDateTime + // + this.labelLastDateTime.Location = new System.Drawing.Point(31, 66); + this.labelLastDateTime.Name = "labelLastDateTime"; + this.labelLastDateTime.Size = new System.Drawing.Size(100, 23); + this.labelLastDateTime.TabIndex = 4; + this.labelLastDateTime.Text = "Last Date Time:"; + this.labelLastDateTime.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // dateTimePickerForLastDateTime + // + this.dateTimePickerForLastDateTime.CustomFormat = "yyyy-MM-dd HH:mm"; + this.dateTimePickerForLastDateTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom; + this.dateTimePickerForLastDateTime.Location = new System.Drawing.Point(137, 66); + this.dateTimePickerForLastDateTime.Name = "dateTimePickerForLastDateTime"; + this.dateTimePickerForLastDateTime.ShowUpDown = true; + this.dateTimePickerForLastDateTime.Size = new System.Drawing.Size(143, 20); + this.dateTimePickerForLastDateTime.TabIndex = 3; + // + // panelGreenTicker + // + this.panelGreenTicker.BackColor = System.Drawing.Color.Green; + this.panelGreenTicker.Location = new System.Drawing.Point(121, 113); + this.panelGreenTicker.Name = "panelGreenTicker"; + this.panelGreenTicker.Size = new System.Drawing.Size(10, 14); + this.panelGreenTicker.TabIndex = 5; + // + // textBoxGreenTicker + // + this.textBoxGreenTicker.Location = new System.Drawing.Point(137, 110); + this.textBoxGreenTicker.Name = "textBoxGreenTicker"; + this.textBoxGreenTicker.Size = new System.Drawing.Size(66, 20); + this.textBoxGreenTicker.TabIndex = 6; + // + // textBoxRedTicker + // + this.textBoxRedTicker.Location = new System.Drawing.Point(137, 146); + this.textBoxRedTicker.Name = "textBoxRedTicker"; + this.textBoxRedTicker.Size = new System.Drawing.Size(66, 20); + this.textBoxRedTicker.TabIndex = 8; + // + // panelRedTicker + // + this.panelRedTicker.BackColor = System.Drawing.Color.Red; + this.panelRedTicker.Location = new System.Drawing.Point(121, 149); + this.panelRedTicker.Name = "panelRedTicker"; + this.panelRedTicker.Size = new System.Drawing.Size(10, 14); + this.panelRedTicker.TabIndex = 7; + // // PairsViewer // *************** *** 81,92 **** this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(292, 262); this.Controls.Add(this.buttonShow); ! this.Controls.Add(this.dateTimePicker); this.Name = "PairsViewer"; this.Text = "PairsViewer"; this.ResumeLayout(false); } private System.Windows.Forms.Button buttonShow; - private System.Windows.Forms.DateTimePicker dateTimePicker; } } --- 146,172 ---- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(292, 262); + this.Controls.Add(this.textBoxRedTicker); + this.Controls.Add(this.panelRedTicker); + this.Controls.Add(this.textBoxGreenTicker); + this.Controls.Add(this.panelGreenTicker); + this.Controls.Add(this.labelLastDateTime); + this.Controls.Add(this.dateTimePickerForLastDateTime); + this.Controls.Add(this.labelFirstDateTime); this.Controls.Add(this.buttonShow); ! this.Controls.Add(this.dateTimePickerForFirstDateTime); this.Name = "PairsViewer"; this.Text = "PairsViewer"; this.ResumeLayout(false); + this.PerformLayout(); } + private System.Windows.Forms.Panel panelRedTicker; + private System.Windows.Forms.TextBox textBoxRedTicker; + private System.Windows.Forms.DateTimePicker dateTimePickerForLastDateTime; + private System.Windows.Forms.TextBox textBoxGreenTicker; + private System.Windows.Forms.Panel panelGreenTicker; + private System.Windows.Forms.Label labelLastDateTime; + private System.Windows.Forms.Label labelFirstDateTime; + private System.Windows.Forms.DateTimePicker dateTimePickerForFirstDateTime; private System.Windows.Forms.Button buttonShow; } } |
|
From: Glauco S. <gla...@us...> - 2009-03-09 17:45:31
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv2765/b7_Scripts/WalkForwardTesting/PairsTrading/Logging Modified Files: PairsViewer.cs Log Message: - a DateTimePicker has been added to chose the final date time for the chart - tickers are now displayed, each with its own line colour Index: PairsViewer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging/PairsViewer.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PairsViewer.cs 7 Mar 2009 04:20:35 -0000 1.1 --- PairsViewer.cs 9 Mar 2009 17:45:13 -0000 1.2 *************** *** 46,50 **** WeightedPosition firstWeightedPosition , WeightedPosition secondWeightedPosition , ! DateTime firstDateTime ) { // --- 46,50 ---- WeightedPosition firstWeightedPosition , WeightedPosition secondWeightedPosition , ! DateTime dateTime ) { // *************** *** 56,83 **** this.firstWeightedPosition = firstWeightedPosition; this.secondWeightedPosition = secondWeightedPosition; ! this.dateTimePicker.Value = firstDateTime; } ! ! #region ButtonShowClick ! ! #region getHistory ! ! #region addItemsToHistory ! private DateTime getFirstDateTime() { ! DateTime firstDateTime = ! this.dateTimePicker.Value.AddMinutes( -10 ); // HistoricalEndOfDayTimer.GetMarketOpen( // this.dateTimePicker.Value.AddDays( 1 ) ); return firstDateTime; } ! private DateTime getLastDateTime() { ! DateTime firstDateTime = this.getFirstDateTime(); DateTime lastDateTime = HistoricalEndOfDayTimer.GetMarketClose( firstDateTime ); return lastDateTime; ! } private void addItemToHistory( WeightedPosition weightedPosition , DateTime dateTime , History history ) --- 56,88 ---- this.firstWeightedPosition = firstWeightedPosition; this.secondWeightedPosition = secondWeightedPosition; ! this.dateTimePickerForFirstDateTime.Value = ! this.initializeFirstDateTime( dateTime ); ! this.textBoxGreenTicker.Text = firstWeightedPosition.Ticker; ! this.textBoxRedTicker.Text = secondWeightedPosition.Ticker; ! ! this.dateTimePickerForLastDateTime.Value = this.initializeLastDateTime(); } ! private DateTime initializeFirstDateTime( DateTime dateTime ) { ! DateTime firstDateTime = dateTime.AddMinutes( -10 ); // HistoricalEndOfDayTimer.GetMarketOpen( // this.dateTimePicker.Value.AddDays( 1 ) ); return firstDateTime; } ! private DateTime initializeLastDateTime() { ! DateTime firstDateTime = this.dateTimePickerForFirstDateTime.Value; DateTime lastDateTime = HistoricalEndOfDayTimer.GetMarketClose( firstDateTime ); return lastDateTime; ! } ! ! #region ButtonShowClick ! ! #region getHistory ! ! #region addItemsToHistory ! private void addItemToHistory( WeightedPosition weightedPosition , DateTime dateTime , History history ) *************** *** 96,101 **** private void addItemsToHistory( WeightedPosition weightedPosition , History history ) { ! DateTime currentDateTime = this.getFirstDateTime(); ! DateTime lastDateTime = this.getLastDateTime(); while ( currentDateTime <= lastDateTime ) { --- 101,106 ---- private void addItemsToHistory( WeightedPosition weightedPosition , History history ) { ! DateTime currentDateTime = this.dateTimePickerForFirstDateTime.Value; ! DateTime lastDateTime = this.dateTimePickerForLastDateTime.Value; while ( currentDateTime <= lastDateTime ) { |
|
From: Glauco S. <gla...@us...> - 2009-03-07 04:42:24
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4905/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables Modified Files: Transactions.cs Log Message: - a new public static property has been added: public static string FieldNameForDateTime - a new public static property has been added: public static string FieldNameForTicker Index: Transactions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables/Transactions.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Transactions.cs 29 Sep 2008 21:14:43 -0000 1.4 --- Transactions.cs 7 Mar 2009 04:42:05 -0000 1.5 *************** *** 11,14 **** --- 11,22 ---- public class Transactions : ReportTable { + public static string FieldNameForDateTime + { + get{ return "DateTime"; } + } + public static string FieldNameForTicker + { + get{ return "InstrumentKey"; } + } public Transactions( string reportName , DataTable detailedDataTable ) : base( reportName + " - Transactions" ) *************** *** 19,25 **** DataTable transactionsDataTable ) { ! transactionsDataTable.Columns.Add( "DateTime" , Type.GetType( "System.DateTime" ) ); // transactionsDataTable.Columns.Add( "BarComponent" , Type.GetType( "System.String" ) ); ! transactionsDataTable.Columns.Add( "TransactionType" , Type.GetType( "System.String" ) ); transactionsDataTable.Columns.Add( "InstrumentKey" , Type.GetType( "System.String" ) ); transactionsDataTable.Columns.Add( "Quantity" , Type.GetType( "System.Int32" ) ); --- 27,35 ---- DataTable transactionsDataTable ) { ! transactionsDataTable.Columns.Add( ! Transactions.FieldNameForDateTime , Type.GetType( "System.DateTime" ) ); // transactionsDataTable.Columns.Add( "BarComponent" , Type.GetType( "System.String" ) ); ! transactionsDataTable.Columns.Add( ! Transactions.FieldNameForTicker , Type.GetType( "System.String" ) ); transactionsDataTable.Columns.Add( "InstrumentKey" , Type.GetType( "System.String" ) ); transactionsDataTable.Columns.Add( "Quantity" , Type.GetType( "System.Int32" ) ); |
|
From: Glauco S. <gla...@us...> - 2009-03-07 04:25:21
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv23111/WalkForwardTesting/PairsTrading/Logging Modified Files: TesterForPairsTradingTestingPositions.cs Log Message: It now uses a PairsViewer object, to analyze the log Index: TesterForPairsTradingTestingPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging/TesterForPairsTradingTestingPositions.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TesterForPairsTradingTestingPositions.cs 28 Feb 2009 18:45:06 -0000 1.7 --- TesterForPairsTradingTestingPositions.cs 7 Mar 2009 04:25:05 -0000 1.8 *************** *** 96,158 **** #region Run ! #region getHistory ! ! #region addItemsToHistory ! private DateTime getFirstDateTime() ! { ! DateTime firstDateTime = ! HistoricalEndOfDayTimer.GetMarketOpen( ! this.dateTimeWhenThisObjectWasLogged.AddDays( 1 ) ); ! return firstDateTime; ! } ! private DateTime getLastDateTime() ! { ! DateTime firstDateTime = this.getFirstDateTime(); ! DateTime lastDateTime = ! HistoricalEndOfDayTimer.GetMarketClose( firstDateTime ); ! return lastDateTime; ! } ! private void addItemToHistory( ! WeightedPosition weightedPosition , DateTime dateTime , History history ) ! { ! try ! { ! double marketValue = this.historicalMarketValueProvider.GetMarketValue( ! weightedPosition.Ticker , dateTime ); ! history.Add( dateTime , marketValue ); ! } ! catch( TickerNotExchangedException tickerNotExchangedException ) ! { ! string toAvoidWarning = tickerNotExchangedException.Message; ! } ! } ! private void addItemsToHistory( WeightedPosition weightedPosition , History history ) ! { ! DateTime currentDateTime = this.getFirstDateTime(); ! DateTime lastDateTime = this.getLastDateTime(); ! while ( currentDateTime <= lastDateTime ) ! { ! this.addItemToHistory( weightedPosition , currentDateTime , history ); ! currentDateTime = currentDateTime.AddMinutes( 1 ); ! } ! } ! #endregion addItemsToHistory ! ! private History getHistory( WeightedPosition weightedPosition ) ! { ! History history = new History(); ! this.addItemsToHistory( weightedPosition , history ); ! return history; ! } ! #endregion getHistory ! private void showHistoriesPlots( ! History historyForFirstPosition , History historyForSecondPosition ) ! { ! HistoriesViewer historiesViewer = new HistoriesViewer(); ! historiesViewer.Add( historyForFirstPosition , Color.Green ); ! historiesViewer.Add( historyForSecondPosition , Color.Red ); ! historiesViewer.ShowDialog(); ! } public void Run() --- 96,158 ---- #region Run ! // #region getHistory ! // ! // #region addItemsToHistory ! // private DateTime getFirstDateTime() ! // { ! // DateTime firstDateTime = ! // HistoricalEndOfDayTimer.GetMarketOpen( ! // this.dateTimeWhenThisObjectWasLogged.AddDays( 1 ) ); ! // return firstDateTime; ! // } ! // private DateTime getLastDateTime() ! // { ! // DateTime firstDateTime = this.getFirstDateTime(); ! // DateTime lastDateTime = ! // HistoricalEndOfDayTimer.GetMarketClose( firstDateTime ); ! // return lastDateTime; ! // } ! // private void addItemToHistory( ! // WeightedPosition weightedPosition , DateTime dateTime , History history ) ! // { ! // try ! // { ! // double marketValue = this.historicalMarketValueProvider.GetMarketValue( ! // weightedPosition.Ticker , dateTime ); ! // history.Add( dateTime , marketValue ); ! // } ! // catch( TickerNotExchangedException tickerNotExchangedException ) ! // { ! // string toAvoidWarning = tickerNotExchangedException.Message; ! // } ! // } ! // private void addItemsToHistory( WeightedPosition weightedPosition , History history ) ! // { ! // DateTime currentDateTime = this.getFirstDateTime(); ! // DateTime lastDateTime = this.getLastDateTime(); ! // while ( currentDateTime <= lastDateTime ) ! // { ! // this.addItemToHistory( weightedPosition , currentDateTime , history ); ! // currentDateTime = currentDateTime.AddMinutes( 1 ); ! // } ! // } ! // #endregion addItemsToHistory ! // ! // private History getHistory( WeightedPosition weightedPosition ) ! // { ! // History history = new History(); ! // this.addItemsToHistory( weightedPosition , history ); ! // return history; ! // } ! // #endregion getHistory ! // private void showHistoriesPlots( ! // History historyForFirstPosition , History historyForSecondPosition ) ! // { ! // HistoriesViewer historiesViewer = new HistoriesViewer(); ! // historiesViewer.Add( historyForFirstPosition , Color.Green ); ! // historiesViewer.Add( historyForSecondPosition , Color.Red ); ! // historiesViewer.Show(); ! // } public void Run() *************** *** 160,168 **** this.historicalMarketValueProvider = new HistoricalBarProvider( new SimpleBarCache( 60 ) ); ! History historyForFirstPosition = this.getHistory( ! this.testingPositions.WeightedPositions[ 0 ] ); ! History historyForSecondPosition = this.getHistory( ! this.testingPositions.WeightedPositions[ 1 ] ); ! this.showHistoriesPlots( historyForFirstPosition , historyForSecondPosition ); } #endregion Run --- 160,173 ---- this.historicalMarketValueProvider = new HistoricalBarProvider( new SimpleBarCache( 60 ) ); ! new PairsViewer( ! this.historicalMarketValueProvider , ! this.testingPositions.WeightedPositions[ 0 ] , ! this.testingPositions.WeightedPositions[ 1 ] , ! this.dateTimeWhenThisObjectWasLogged ).Show(); ! // History historyForFirstPosition = this.getHistory( ! // this.testingPositions.WeightedPositions[ 0 ] ); ! // History historyForSecondPosition = this.getHistory( ! // this.testingPositions.WeightedPositions[ 1 ] ); ! // this.showHistoriesPlots( historyForFirstPosition , historyForSecondPosition ); } #endregion Run |
|
From: Glauco S. <gla...@us...> - 2009-03-07 04:23:25
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/CallingReportsForRunScripts In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv21742/CallingReportsForRunScripts Modified Files: ShowReportFromFile.cs Log Message: the method ShowReportFromSerializedAccountReport() returns a Report, now (it was void in the previous revision) Index: ShowReportFromFile.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/CallingReportsForRunScripts/ShowReportFromFile.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ShowReportFromFile.cs 29 Sep 2008 21:16:45 -0000 1.6 --- ShowReportFromFile.cs 7 Mar 2009 04:23:19 -0000 1.7 *************** *** 61,71 **** } ! public static void ShowReportFromSerializedAccountReport(string serializedAccountReportFullPath) { try { AccountReport accountReport = (AccountReport)ObjectArchiver.Extract(serializedAccountReportFullPath); ! Report report = new Report(accountReport); report.Text = serializedAccountReportFullPath.Substring(serializedAccountReportFullPath.LastIndexOf("\\") + 1); --- 61,73 ---- } ! public static Report ShowReportFromSerializedAccountReport( ! string serializedAccountReportFullPath ) { + Report report = null; try { AccountReport accountReport = (AccountReport)ObjectArchiver.Extract(serializedAccountReportFullPath); ! report = new Report(accountReport); report.Text = serializedAccountReportFullPath.Substring(serializedAccountReportFullPath.LastIndexOf("\\") + 1); *************** *** 76,79 **** --- 78,82 ---- System.Windows.Forms.MessageBox.Show(ex.ToString()); } + return report; } |
|
From: Glauco S. <gla...@us...> - 2009-03-07 04:22:21
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17923 Modified Files: Scripts_SD.csproj Log Message: - WalkForwardTesting\PairsTrading\Logging\PairsTradingSerializedReportViewer.cs has been added - WalkForwardTesting\PairsTrading\Logging\PairsViewer.cs has been added - WalkForwardTesting\PairsTrading\Logging\PairsViewer.Designer.cs has been added Index: Scripts_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/Scripts_SD.csproj,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** Scripts_SD.csproj 28 Feb 2009 18:30:11 -0000 1.36 --- Scripts_SD.csproj 7 Mar 2009 04:22:06 -0000 1.37 *************** *** 126,129 **** --- 126,134 ---- <Compile Include="WalkForwardTesting\PairsTrading\InSample\PairsTradingFitnessEvaluator.cs" /> <Compile Include="WalkForwardTesting\PairsTrading\Logging\PairsTradingLogItem.cs" /> + <Compile Include="WalkForwardTesting\PairsTrading\Logging\PairsTradingSerializedReportViewer.cs" /> + <Compile Include="WalkForwardTesting\PairsTrading\Logging\PairsViewer.cs" /> + <Compile Include="WalkForwardTesting\PairsTrading\Logging\PairsViewer.Designer.cs"> + <DependentUpon>PairsViewer.cs</DependentUpon> + </Compile> <Compile Include="WalkForwardTesting\PairsTrading\Logging\TesterForPairsTradingTestingPositionsEndOfDayInSample.cs" /> <Compile Include="WalkForwardTesting\PairsTrading\Logging\TesterForPairsTradingTestingPositions.cs" /> |
|
From: Glauco S. <gla...@us...> - 2009-03-07 04:21:05
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14931/WalkForwardTesting/PairsTrading/Logging Added Files: PairsViewer.Designer.cs Log Message: Form used to display two pairs trading candidates --- NEW FILE: PairsViewer.Designer.cs --- (This appears to be a binary file; contents omitted.) |
|
From: Glauco S. <gla...@us...> - 2009-03-07 04:20:46
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14871/WalkForwardTesting/PairsTrading/Logging Added Files: PairsViewer.cs Log Message: Form used to display two pairs trading candidates --- NEW FILE: PairsViewer.cs --- /* QuantProject - Quantitative Finance Library PairsViewer.cs Copyright (C) 2009 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Drawing; using System.Windows.Forms; using QuantProject.ADT.Histories; using QuantProject.Business.DataProviders; using QuantProject.Business.Strategies; using QuantProject.Business.Timing; using QuantProject.Presentation; namespace QuantProject.Scripts.WalkForwardTesting.PairsTrading { /// <summary> /// Form used to display two pairs trading candidates /// </summary> public partial class PairsViewer : Form { private HistoricalMarketValueProvider historicalMarketValueProvider; private WeightedPosition firstWeightedPosition; private WeightedPosition secondWeightedPosition; public PairsViewer( HistoricalMarketValueProvider historicalMarketValueProvider , WeightedPosition firstWeightedPosition , WeightedPosition secondWeightedPosition , DateTime firstDateTime ) { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); this.historicalMarketValueProvider = historicalMarketValueProvider; this.firstWeightedPosition = firstWeightedPosition; this.secondWeightedPosition = secondWeightedPosition; this.dateTimePicker.Value = firstDateTime; } #region ButtonShowClick #region getHistory #region addItemsToHistory private DateTime getFirstDateTime() { DateTime firstDateTime = this.dateTimePicker.Value.AddMinutes( -10 ); // HistoricalEndOfDayTimer.GetMarketOpen( // this.dateTimePicker.Value.AddDays( 1 ) ); return firstDateTime; } private DateTime getLastDateTime() { DateTime firstDateTime = this.getFirstDateTime(); DateTime lastDateTime = HistoricalEndOfDayTimer.GetMarketClose( firstDateTime ); return lastDateTime; } private void addItemToHistory( WeightedPosition weightedPosition , DateTime dateTime , History history ) { try { double marketValue = this.historicalMarketValueProvider.GetMarketValue( weightedPosition.Ticker , dateTime ); history.Add( dateTime , marketValue ); } catch( TickerNotExchangedException tickerNotExchangedException ) { string toAvoidWarning = tickerNotExchangedException.Message; } } private void addItemsToHistory( WeightedPosition weightedPosition , History history ) { DateTime currentDateTime = this.getFirstDateTime(); DateTime lastDateTime = this.getLastDateTime(); while ( currentDateTime <= lastDateTime ) { this.addItemToHistory( weightedPosition , currentDateTime , history ); currentDateTime = currentDateTime.AddMinutes( 1 ); } } #endregion addItemsToHistory private History getHistory( WeightedPosition weightedPosition ) { History history = new History(); this.addItemsToHistory( weightedPosition , history ); return history; } #endregion getHistory private void showHistoriesPlots( History historyForFirstPosition , History historyForSecondPosition ) { HistoriesViewer historiesViewer = new HistoriesViewer(); historiesViewer.Add( historyForFirstPosition , Color.Green ); historiesViewer.Add( historyForSecondPosition , Color.Red ); historiesViewer.Show(); } void ButtonShowClick(object sender, EventArgs e) { History historyForFirstPosition = this.getHistory( this.firstWeightedPosition ); History historyForSecondPosition = this.getHistory( this.secondWeightedPosition ); this.showHistoriesPlots( historyForFirstPosition , historyForSecondPosition ); } #endregion ButtonShowClick } } |
|
From: Glauco S. <gla...@us...> - 2009-03-07 04:20:25
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Logging In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14632/WalkForwardTesting/PairsTrading/Logging Added Files: PairsTradingSerializedReportViewer.cs Log Message: Opens a serialized report and analyzes it --- NEW FILE: PairsTradingSerializedReportViewer.cs --- /* QuantProject - Quantitative Finance Library PairsTradingSerializedReportViewer.cs Copyright (C) 2009 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Data; using System.Windows.Forms; using QuantProject.ADT.FileManaging; using QuantProject.Business.DataProviders; using QuantProject.Business.Financial.Accounting.Reporting; using QuantProject.Business.Financial.Accounting.Reporting.Tables; using QuantProject.Business.Strategies; using QuantProject.Data.DataProviders.Bars.Caching; using QuantProject.Presentation.Reporting.WindowsForm; using QuantProject.Scripts.CallingReportsForRunScripts; namespace QuantProject.Scripts.WalkForwardTesting.PairsTrading { /// <summary> /// Opens a serialized report and analyzes it /// </summary> public class PairsTradingSerializedReportViewer { private string fullPathFileNameForSerializedAccountReport; private AccountReport accountReport; public PairsTradingSerializedReportViewer() { } #region Run #region createAccountReportFromSerialization private string getFullPathFileNameForSerializedAccountReport() { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Title = "Select a serialized report please ..."; openFileDialog.Multiselect = false; openFileDialog.CheckFileExists = true; openFileDialog.Filter = "Account Reports (*.qpr)|*.qpr"; openFileDialog.ShowDialog(); return openFileDialog.FileName; } private void getAccountReport( string fullPathFileNameForSerializedAccountReport ) { this.accountReport = (AccountReport)ObjectArchiver.Extract( fullPathFileNameForSerializedAccountReport ); Report report = new Report( accountReport ); report.Text = fullPathFileNameForSerializedAccountReport.Substring( fullPathFileNameForSerializedAccountReport.LastIndexOf("\\") + 1 ); } private void createAccountReportFromSerialization() { this.fullPathFileNameForSerializedAccountReport = this.getFullPathFileNameForSerializedAccountReport(); this.accountReport = (AccountReport)ObjectArchiver.Extract( this.fullPathFileNameForSerializedAccountReport ); } #endregion createAccountReportFromSerialization #region displayAccountReport private void displayAccountReport() { Report report = new Report( this.accountReport ); report.Text = this.fullPathFileNameForSerializedAccountReport.Substring( this.fullPathFileNameForSerializedAccountReport.LastIndexOf("\\") + 1); report.Show(); } #endregion displayAccountReport #region displayReport private Report displayReport() { string fullPathFileNameForSerializedAccountReport = this.getFullPathFileNameForSerializedAccountReport(); Report report = ShowReportFromFile.ShowReportFromSerializedAccountReport( fullPathFileNameForSerializedAccountReport ); return report; } #endregion displayReport private void addEventHandlerToReport( Report report ) { report.TransactionGrid.RightClickedTransaction += new RightClickedTransactionEventHandler( this.rightClickedTransactionEventHandler ); } public void Run() { Report report = this.displayReport(); // this.createAccountReportFromSerialization(); this.addEventHandlerToReport( report ); } #endregion Run #region rightClickedTransactionEventHandler #region getPairsViewerParameters private AccountReport getAccountReport( ReportGrid reportGrid ) { Report report = (Report)reportGrid.FindForm(); AccountReport accountReport = report.AccountReport; return accountReport; } #region getTransactionsDataRows #region getRowIndexForTheFirstTransactionDataRow private bool hasThePreviousDataRowTheSameDateTime( Transactions transactions , int rowIndex ) { DataRow transactionForRowIndex = transactions.DataTable.Rows[ rowIndex ]; DataRow transactionForPreviousIndex = transactions.DataTable.Rows[ rowIndex - 1 ]; bool hasTheSameTime = ( (DateTime)transactionForRowIndex[ Transactions.FieldNameForDateTime ] == (DateTime)transactionForPreviousIndex[ Transactions.FieldNameForDateTime ] ); return hasTheSameTime; } private int getRowIndexForTheFirstTransactionDataRow( Transactions transactions , int rowIndex ) { int rowIndexForTheFirstTransactionDataRow = rowIndex; if ( ( rowIndex > 0 ) && this.hasThePreviousDataRowTheSameDateTime( transactions , rowIndex ) ) rowIndexForTheFirstTransactionDataRow -- ; return rowIndexForTheFirstTransactionDataRow; } #endregion getRowIndexForTheFirstTransactionDataRow private void getTransactionsDataRowsWithRowIndexForTheFirstTransactionDataRow( Transactions transactions , int rowIndexForTheFirstTransactionDataRow , out DataRow firstTransactionDataRow , out DataRow secondTransactionDataRow ) { firstTransactionDataRow = transactions.DataTable.Rows[ rowIndexForTheFirstTransactionDataRow ]; secondTransactionDataRow = transactions.DataTable.Rows[ rowIndexForTheFirstTransactionDataRow + 1 ]; } private void getTransactionsDataRows( Transactions transactions , int rowIndex , out DataRow firstTransactionDataRow , out DataRow secondTransactionDataRow ) { int rowIndexForTheFirstTransactionDataRow = this.getRowIndexForTheFirstTransactionDataRow( transactions , rowIndex ); this.getTransactionsDataRowsWithRowIndexForTheFirstTransactionDataRow( transactions , rowIndexForTheFirstTransactionDataRow , out firstTransactionDataRow , out secondTransactionDataRow ); } #endregion getTransactionsDataRows private void getPairsViewerParameters( DataRow firstTransactionDataRow , DataRow secondTransactionDataRow , out DateTime clickedDateTime , out string firstTicker , out string secondTicker ) { clickedDateTime = (DateTime)firstTransactionDataRow[ Transactions.FieldNameForDateTime ]; firstTicker = (string)firstTransactionDataRow[ Transactions.FieldNameForTicker ]; secondTicker = (string)secondTransactionDataRow[ Transactions.FieldNameForTicker ]; } private void getPairsViewerParameters( AccountReport accountReport , int rowIndex , out DateTime clickedDateTime , out string firstTicker , out string secondTicker ) { DataRow firstTransactionDataRow; DataRow secondTransactionDataRow; this.getTransactionsDataRows( (Transactions)accountReport.TransactionTable , rowIndex , out firstTransactionDataRow , out secondTransactionDataRow ); this.getPairsViewerParameters( firstTransactionDataRow , secondTransactionDataRow , out clickedDateTime , out firstTicker , out secondTicker ); } private void getPairsViewerParameters( ReportGrid reportGrid , int rowIndex , out DateTime clickedDateTime , out string firstTicker , out string secondTicker ) { AccountReport accountReport = this.getAccountReport( reportGrid ); this.getPairsViewerParameters( accountReport , rowIndex , out clickedDateTime , out firstTicker , out secondTicker ); } #endregion getPairsViewerParameters private void runPairsViewer( DateTime clickedDateTime , string firstTicker , string secondTicker ) { WeightedPosition firstWeightedPosition = new WeightedPosition( 0.5 , firstTicker ); WeightedPosition secondWeightedPosition = new WeightedPosition( 0.5 , secondTicker ); PairsViewer pairsViewer = new PairsViewer( new HistoricalBarProvider( new SimpleBarCache( 60 ) ) , firstWeightedPosition , secondWeightedPosition , clickedDateTime ); pairsViewer.Show(); } private void rightClickedTransactionEventHandler( ReportGrid reportGrid , int rowIndex ) { DateTime clickedDateTime; string firstTicker; string secondTicker; this.getPairsViewerParameters( reportGrid , rowIndex , out clickedDateTime , out firstTicker , out secondTicker ); this.runPairsViewer( clickedDateTime , firstTicker , secondTicker ); } #endregion rightClickedTransactionEventHandler } } |
|
From: Glauco S. <gla...@us...> - 2009-03-07 04:17:11
|
Update of /cvsroot/quantproject/QuantProject/b5_Presentation/Reporting/WindowsForm In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv8294/b5_Presentation/Reporting/WindowsForm Modified Files: ReportGrid.cs Log Message: A new RightClickedTransaction event has been added (it is thrown when a transaction is right clicked on the report) Index: ReportGrid.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b5_Presentation/Reporting/WindowsForm/ReportGrid.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ReportGrid.cs 29 Sep 2008 21:15:57 -0000 1.3 --- ReportGrid.cs 7 Mar 2009 04:16:57 -0000 1.4 *************** *** 28,31 **** --- 28,34 ---- namespace QuantProject.Presentation.Reporting.WindowsForm { + public delegate void RightClickedTransactionEventHandler( + ReportGrid sender , int dataGridRowNumber ); + /// <summary> /// DataGrid to be displayed within a report TabPage *************** *** 34,37 **** --- 37,42 ---- public class ReportGrid : DataGrid { + public event RightClickedTransactionEventHandler RightClickedTransaction; + private ReportTable reportTable; private DataGridTableStyle dataGridStyle; *************** *** 42,45 **** --- 47,51 ---- this.DataSource = reportTable.DataTable; this.setFormat(); + this.MouseDown += new MouseEventHandler( this.mouseDownEventHandler ); } *************** *** 66,70 **** // ( DataGridTextBoxColumn )dataGridTableStyle.GridColumnStyles[ // columnIndex ]; ! //// dataGridTableStyle.GridColumnStyles.a // return dataGridTextBoxColumn; // } --- 72,76 ---- // ( DataGridTextBoxColumn )dataGridTableStyle.GridColumnStyles[ // columnIndex ]; ! //// dataGridTableStyle.GridColumnStyles.a // return dataGridTextBoxColumn; // } *************** *** 107,110 **** --- 113,140 ---- } #endregion setFormat + + #region mouseDownEventHandler + + #region handleRightClick + private int getClickedRowIndex( MouseEventArgs mouseEventArgs ) + { + DataGrid.HitTestInfo hitTestInfo = this.HitTest( + mouseEventArgs.X , mouseEventArgs.Y ); + int rowIndex = hitTestInfo.Row; + return rowIndex; + } + private void handleRightClick( object sender , MouseEventArgs mouseEventArgs ) + { + int rowIndex = this.getClickedRowIndex( mouseEventArgs ); + this.RightClickedTransaction( this , rowIndex ); + } + #endregion handleRightClick + + private void mouseDownEventHandler( object sender , MouseEventArgs mouseEventArgs ) + { + if ( mouseEventArgs.Button == MouseButtons.Right ) + this.handleRightClick( sender , mouseEventArgs ); + } + #endregion mouseDownEventHandler } } |
|
From: Glauco S. <gla...@us...> - 2009-03-07 04:15:58
|
Update of /cvsroot/quantproject/QuantProject/b91_QuantProject In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3149/b91_QuantProject Modified Files: Main.cs Log Message: It shows how to use the class PairsTradingSerializedReportViewer, to analyze a serialized report, by visualizing pairs charts Index: Main.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b91_QuantProject/Main.cs,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** Main.cs 29 Sep 2008 21:22:01 -0000 1.22 --- Main.cs 7 Mar 2009 04:15:29 -0000 1.23 *************** *** 475,479 **** // new FixedLengthTwoPhasesMain().Run(); ! new PairsTradingMain().Run(); // new RunOneRank().Run(); --- 475,480 ---- // new FixedLengthTwoPhasesMain().Run(); ! new PairsTradingSerializedReportViewer().Run(); ! // new PairsTradingMain().Run(); // new RunOneRank().Run(); |