quantproject-developers Mailing List for QuantProject (Page 95)
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. <mar...@li...> - 2005-12-29 15:33:07
|
> > Come faccio ad usarlo? C'e' una chiamata nel main da "scommentare"? come tutti i runEcc. : new run(parametri).Run(); Ma mi sa che non ho capito che cosa intendi ... > Vedo dal log che si basa sui genomi. Credo sarebbe molto utile integrarlo > con un sistema che ho fatto io per la one rank: si preme tasto destro sul > DataGrid delle transazioni e automaticamente un oggetto si calcola l'array > di signed tickers che sta "piu' vicino" al punto del click (in pratica > risale al genoma). E' utile quando si recupera un account per il quale non > sono stati salvati i genomi, oppure quando si vede un punto interessante > nel grafico e si vuole analizzare l'andamento del genoma corrispondente: > basta andare nel DataGrid delle transazioni e clickare col destro. > Se mi fai vedere un esempio di come usare RunEfficientOTCTypes partendo da > un genoma, aggiungo io il codice per fare il tutto (partendo dalle > transazioni nel report). |
|
From: Glauco S. <gl...@my...> - 2005-12-28 23:49:36
|
Come faccio ad usarlo? C'e' una chiamata nel main da "scommentare"? Vedo dal log che si basa sui genomi. Credo sarebbe molto utile integrarlo con un sistema che ho fatto io per la one rank: si preme tasto destro sul DataGrid delle transazioni e automaticamente un oggetto si calcola l'array di signed tickers che sta "piu' vicino" al punto del click (in pratica risale al genoma). E' utile quando si recupera un account per il quale non sono stati salvati i genomi, oppure quando si vede un punto interessante nel grafico e si vuole analizzare l'andamento del genoma corrispondente: basta andare nel DataGrid delle transazioni e clickare col destro. Se mi fai vedere un esempio di come usare RunEfficientOTCTypes partendo da un genoma, aggiungo io il codice per fare il tutto (partendo dalle transazioni nel report). At 11:22 PM 12/28/2005 +0000, you wrote: >Update of >/cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/TestingOTCTypes >In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26303/TestingOTCTypes > >Added Files: > RunEfficientOTCTypes.cs EndOfDayTimerHandlerOTCTypes.cs >Log Message: >Added files for testing optimized OpenToClose genomes >in several manners (daily, multiday, OTC - CTO combined, only CTO, etc.) > >--- NEW FILE: RunEfficientOTCTypes.cs --- >/* >QuantProject - Quantitative Finance Library > >RunEfficientOTCTypes.cs >Copyright (C) 2003 >Marco Milletti > >This program is free software; you can redistribute it and/or >modify it under the terms of the GNU General Public License >as published by the Free Software Foundation; either version 2 >of the License, or (at your option) any later version. > >This program is distributed in the hope that it will be useful, >but WITHOUT ANY WARRANTY; without even the implied warranty of >MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >GNU General Public License for more details. > >You should have received a copy of the GNU General Public License >along with this program; if not, write to the Free Software >Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. >*/ > >using System; >using System.Collections; >using System.Data; >using QuantProject.ADT; >using QuantProject.ADT.Optimizing.Genetic; >using QuantProject.ADT.FileManaging; >using QuantProject.Business.DataProviders; >using QuantProject.Business.Financial.Accounting; >using QuantProject.Business.Financial.Accounting.Reporting; >using QuantProject.Business.Financial.Instruments; >using QuantProject.Business.Financial.Ordering; >using QuantProject.Business.Scripting; >using QuantProject.Business.Strategies; >using QuantProject.Business.Testing; >using QuantProject.Business.Timing; >using QuantProject.Business.Financial.Accounting.Commissions; >using QuantProject.Data.DataProviders; >using QuantProject.Data.Selectors; >using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; >using QuantProject.Presentation.Reporting.WindowsForm; >using QuantProject.Scripts.WalkForwardTesting.LinearCombination; > > >namespace QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios >{ > > /// <summary> > /// Script to test OTC daily, OTC multiday and OTC - CTO > /// all together with one optimization and 3 accounts (each for > /// each type of strategy) > /// </summary> > [Serializable] > public class RunEfficientOTCTypes : RunEfficientPortfolio > { > protected int numDaysBetweenEachOptimization; > private Account[] accounts; > > public RunEfficientOTCTypes(string tickerGroupID, int > numberOfEligibleTickers, > int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, > int generationNumberForGeneticOptimizer, > int populationSizeForGeneticOptimizer, string benchmark, > DateTime startDate, DateTime endDate, double targetReturn, > PortfolioType portfolioType, double maxRunningHours, > int numDaysBetweenEachOptimization): > base(tickerGroupID, numberOfEligibleTickers, > numberOfTickersToBeChosen, numDaysForOptimizationPeriod, > generationNumberForGeneticOptimizer, > populationSizeForGeneticOptimizer, benchmark, > startDate, endDate, targetReturn, > portfolioType, maxRunningHours) > { > this.ScriptName = "OTC_Types"; > this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; > this.accounts = new Account[4]; > } > > #region auxiliary overriden methods for Run > > > protected override void run_initializeAccount() > { > for(int i = 0; i<this.accounts.Length; i++) > { > this.accounts[i] = new Account( this.ScriptName, this.endOfDayTimer , > new HistoricalEndOfDayDataStreamer( > this.endOfDayTimer , > this.historicalQuoteProvider ) , > new HistoricalEndOfDayOrderExecutor( > this.endOfDayTimer , > this.historicalQuoteProvider )); > } > > } > > > protected override void run_initializeEndOfDayTimerHandler() > { > this.endOfDayTimerHandler = new > EndOfDayTimerHandlerOTCTypes(this.tickerGroupID, > this.numberOfEligibleTickers, > this.numberOfTickersToBeChosen, > this.numDaysForOptimizationPeriod, > this.generationNumberForGeneticOptimizer, > this.populationSizeForGeneticOptimizer, > this.benchmark, > this.targetReturn, > this.portfolioType, this.numDaysBetweenEachOptimization, > this.accounts); > } > > protected override void run_initializeHistoricalQuoteProvider() > { > //this.historicalQuoteProvider = new HistoricalRawQuoteProvider(); > this.historicalQuoteProvider = new HistoricalAdjustedQuoteProvider(); > } > > protected override void run_addEventHandlers() > { > this.endOfDayTimer.MarketOpen += > new MarketOpenEventHandler( > this.endOfDayTimerHandler.MarketOpenEventHandler); > > this.endOfDayTimer.MarketClose += > new MarketCloseEventHandler( > this.endOfDayTimerHandler.MarketCloseEventHandler); > > this.endOfDayTimer.MarketClose += > new MarketCloseEventHandler( > this.checkDateForReport); > > this.endOfDayTimer.OneHourAfterMarketClose += > new OneHourAfterMarketCloseEventHandler( > this.endOfDayTimerHandler.OneHourAfterMarketCloseEventHandler ); > } > #endregion > > //necessary far calling RunEfficientPortfolio.Run() > //in classes that inherit from this class > public override void Run() > { > base.Run(); > } > public override void SaveScriptResults() > { > string fileName = "From"+this.numberOfEligibleTickers + > "OptDays" + this.numDaysForOptimizationPeriod + "Portfolio" + > this.numberOfTickersToBeChosen + "GenNum" + > this.generationNumberForGeneticOptimizer + > "PopSize" + this.populationSizeForGeneticOptimizer + > "Target" + Convert.ToString(this.targetReturn) + > Convert.ToString(this.portfolioType); > string dirNameWhereToSaveAccounts = > System.Configuration.ConfigurationSettings.AppSettings["AccountsArchive"] + > "\\" + this.ScriptName + "\\"; > string dirNameWhereToSaveTransactions = > System.Configuration.ConfigurationSettings.AppSettings["TransactionsArchive"] + > "\\" + this.ScriptName + "\\"; > string dirNameWhereToSaveBestGenomes = > System.Configuration.ConfigurationSettings.AppSettings["GenomesArchive"] + > "\\" + this.ScriptName + "\\"; > > >this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveAccounts); > >this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveTransactions); > >this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveBestGenomes); > > for(int i = 0; i<this.accounts.Length; i++) > { > ObjectArchiver.Archive(accounts[i], > dirNameWhereToSaveAccounts + > fileName + "#" + i.ToString() + ".qPa"); > ObjectArchiver.Archive(this.accounts[i].Transactions, > dirNameWhereToSaveTransactions + > fileName + "#" + i.ToString() + ".qPt"); > } > OptimizationOutput optimizationOutput = new OptimizationOutput(); > foreach(GenomeRepresentation genomeRepresentation in > this.endOfDayTimerHandler.BestGenomes) > optimizationOutput.Add(genomeRepresentation); > ObjectArchiver.Archive(optimizationOutput, > dirNameWhereToSaveBestGenomes + > fileName + ".bgn"); > this.endOfDayTimer.Stop(); > } > } >} > >--- NEW FILE: EndOfDayTimerHandlerOTCTypes.cs --- >/* >QuantProject - Quantitative Finance Library > >EndOfDayTimerHandlerOTCTypes.cs >Copyright (C) 2003 >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 System.Collections; > >using QuantProject.ADT; >using QuantProject.Business.Financial.Accounting; >using QuantProject.Business.Financial.Instruments; >using QuantProject.Business.Financial.Ordering; >using QuantProject.Business.Timing; >using QuantProject.Data.DataProviders; >using QuantProject.Data.Selectors; >using QuantProject.ADT.Optimizing.Genetic; > >namespace QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios >{ > > /// <summary> > /// Implements MarketOpenEventHandler, > /// MarketCloseEventHandler and OneHourAfterMarketCloseEventHandler > /// These handlers run all the > /// OTC strategy types after a common optimization, for testing purposes > /// </summary> > [Serializable] > public class EndOfDayTimerHandlerOTCTypes : EndOfDayTimerHandler > { > private int numDaysBetweenEachOptimization; > private int numDaysElapsedSinceLastOptimization; > private int seedForRandomGenerator; > private Account[] accounts; > //private ArrayList[] ordersForAccounts; > > public EndOfDayTimerHandlerOTCTypes(string tickerGroupID, int > numberOfEligibleTickers, > int numberOfTickersToBeChosen, int > numDaysForOptimizationPeriod, > int generationNumberForGeneticOptimizer, > int populationSizeForGeneticOptimizer, > string benchmark, double targetReturn, > PortfolioType portfolioType, int > numDaysBetweenEachOptimization, > Account[] accounts): > base(tickerGroupID, numberOfEligibleTickers, > numberOfTickersToBeChosen, > numDaysForOptimizationPeriod, accounts[0], > generationNumberForGeneticOptimizer, > populationSizeForGeneticOptimizer, > benchmark, targetReturn, > portfolioType) > { > this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; > this.numDaysElapsedSinceLastOptimization = 0; > this.seedForRandomGenerator = > ConstantsProvider.SeedForRandomGenerator; > this.accounts = accounts; > //for(int i = 0; i<this.accounts.Length;i++) > //ordersForAccounts[i] = new ArrayList(); > } > >// protected override void addChosenTickersToOrderList() >// { >// for(int i = 0; i<this.accounts.Length; i++) >// { >// if(i==0)//OTC daily >// {} >// if(i==1) >// {} >// if(i==2) >// {} >// for(int j = 0; j<this.numberOfTickersToBeChosen; j++) >// { >// string ticker = this.chosenTickersForAccounts[i,j]; >// if( ticker != null) >// { >// this.addOrderForTickerForEachAccount(i, ticker ); >// this.lastOrderedTickersForAccounts[i,j] = >// GenomeManagerForEfficientPortfolio.GetCleanTickerCode(ticker); >// } >// } >// } >// } > private void openPositions_openWhenPortfolioIsEmpty(int accountNumber) > { > if(this.accounts[accountNumber].Portfolio.Count == 0) > { > foreach(object item in this.orders) > this.accounts[accountNumber].AddOrder((Order)item); > } > } > > protected override void openPositions() > { > this.addChosenTickersToOrderList(); > for(int i = 0; i<this.accounts.Length; i++) > { > //add cash first for each account > if(this.orders.Count == 0 && this.accounts[i].Transactions.Count > == 0) > this.accounts[i].AddCash(30000); > > if(i<=1)//daily classical, and multiday > this.openPositions_openWhenPortfolioIsEmpty(i); > else if(i==2)//for the CTO OTC > { > this.closePositions_close(i); > foreach(object item in this.orders) > this.accounts[i].AddOrder((Order)item); > } > else if(i==3)//for the CTO, only at night > { > this.closePositions_close(i); > } > } > } > > > private void closePositions_close(int accountNumber) > { > string ticker; > if(this.accounts[accountNumber].Portfolio.Count >0) > { > for(int j = 0; j<this.lastOrderedTickers.Length; j++) > { > ticker = this.lastOrderedTickers[j]; > if( ticker != null) > { > if(this.accounts[accountNumber].Portfolio[ticker]!=null) > this.accounts[accountNumber].ClosePosition(ticker); > } > } > } > } > > > > protected override void closePositions() > { > for(int i=0; i<this.accounts.Length; i++) > { > if(i==0)//OTC daily account > this.closePositions_close(i); > if(i==1)//OTC 2 days > { > if(this.numDaysElapsedSinceLastOptimization == > this.numDaysBetweenEachOptimization - 1) > this.closePositions_close(i); > } > if(i==2)//OTC-CTO > { > this.closePositions_close(i); > if(this.numDaysElapsedSinceLastOptimization < > this.numDaysBetweenEachOptimization - 1) > //open reverse positions at night > { > this.reverseSignOfChosenTickers(); > this.orders.Clear(); > this.addChosenTickersToOrderList(); > this.openPositions_openWhenPortfolioIsEmpty(i); > this.reverseSignOfChosenTickers(); > this.orders.Clear(); > } > } > if(i==3)//CTO, only at night > { >// this.closePositions_close(i); > if(this.numDaysElapsedSinceLastOptimization < > this.numDaysBetweenEachOptimization - 1) > //open reverse positions at night > { > this.reverseSignOfChosenTickers(); > this.orders.Clear(); > this.addChosenTickersToOrderList(); > this.openPositions_openWhenPortfolioIsEmpty(i); > this.reverseSignOfChosenTickers(); > this.orders.Clear(); > } > } > } > } > private void reverseSignOfChosenTickers() > { > for(int i = 0; i<this.chosenTickers.Length; i++) > { > if(this.chosenTickers[i] != null) > { > if(this.chosenTickers[i].StartsWith("-")) > this.chosenTickers[i] = > >GenomeManagerForEfficientPortfolio.GetCleanTickerCode(this.chosenTickers[i]); > else > this.chosenTickers[i] = "-" + this.chosenTickers[i]; > } > } > } > > /// <summary> > /// Handles a "Market Open" event. > /// </summary> > /// <param name="sender"></param> > /// <param name="eventArgs"></param> > public override void MarketOpenEventHandler( > Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) > { > //temporarily the if condition > //if(this.numDaysElapsedSinceLastOptimization == 0) > this.openPositions(); > } > > > public override void MarketCloseEventHandler( > Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) > { > > //temporarily > //if(this.numDaysElapsedSinceLastOptimization == > // this.numDaysBetweenEachOptimization) > this.closePositions(); > > } > > > > #region OneHourAfterMarketCloseEventHandler > > protected DataTable getSetOfTickersToBeOptimized(DateTime currentDate) > { > /* > SelectorByAverageRawOpenPrice selectorByOpenPrice = > new SelectorByAverageRawOpenPrice(this.tickerGroupID, > false, > currentDate.AddDays(-this.numDaysForLiquidity), > currentDate, > this.numberOfEligibleTickers, > this.minPriceForMinimumCommission, > this.maxPriceForMinimumCommission, 0, 2); > DataTable tickersByPrice = > selectorByOpenPrice.GetTableOfSelectedTickers(); > */ > > SelectorByGroup temporizedGroup = new > SelectorByGroup(this.tickerGroupID, currentDate); > SelectorByOpenCloseCorrelationToBenchmark > lessCorrelatedFromTemporizedGroup = > new > SelectorByOpenCloseCorrelationToBenchmark(temporizedGroup.GetTableOfSelectedTickers(), > this.benchmark,true, > >currentDate.AddDays(-this.numDaysForOptimizationPeriod ), > >currentDate, > >this.numberOfEligibleTickers); > > this.eligibleTickers = > lessCorrelatedFromTemporizedGroup.GetTableOfSelectedTickers(); > SelectorByQuotationAtEachMarketDay quotedAtEachMarketDayFromEligible = > new SelectorByQuotationAtEachMarketDay( this.eligibleTickers, > false, > currentDate.AddDays(-this.numDaysForOptimizationPeriod), > currentDate, > this.numberOfEligibleTickers, this.benchmark); > //SelectorByWinningOpenToClose winners = > // new > SelectorByWinningOpenToClose(quotedAtEachMarketDayFromMostLiquid.GetTableOfSelectedTickers(), > // false, > currentDate.AddDays(-2), > // currentDate, > this.numberOfEligibleTickers/4); > //return winners.GetTableOfSelectedTickers(); > //SelectorByOpenCloseCorrelationToBenchmark lessCorrelated = > // new > SelectorByOpenCloseCorrelationToBenchmark(quotedAtEachMarketDayFromEligible.GetTableOfSelectedTickers(), > // this.benchmark, true, > // > currentDate.AddDays(-this.numDaysForLiquidity), > // currentDate, > this.numberOfEligibleTickers/2); > return quotedAtEachMarketDayFromEligible.GetTableOfSelectedTickers(); > //return lessCorrelated.GetTableOfSelectedTickers(); > } > > protected virtual void setTickers(DateTime currentDate, > bool setGenomeCounter) > { > > DataTable setOfTickersToBeOptimized = > this.getSetOfTickersToBeOptimized(currentDate); > if(setOfTickersToBeOptimized.Rows.Count > this.chosenTickers.Length*2) > //the optimization process is possible only if the initial set of > tickers is > //as large as the number of tickers to be chosen > > { > IGenomeManager genManEfficientCTOPortfolio = > new > GenomeManagerForEfficientCTOPortfolio(setOfTickersToBeOptimized, > >currentDate.AddDays(-this.numDaysForOptimizationPeriod), > currentDate, > >this.numberOfTickersToBeChosen, > this.targetReturn, > >this.portfolioType); > > GeneticOptimizer GO = new > GeneticOptimizer(genManEfficientCTOPortfolio, > >this.populationSizeForGeneticOptimizer, > >this.generationNumberForGeneticOptimizer, > >this.seedForRandomGenerator); > if(setGenomeCounter) > this.genomeCounter = new GenomeCounter(GO); > > GO.Run(false); > >this.addGenomeToBestGenomes(GO.BestGenome,currentDate.AddDays(-this.numDaysForOptimizationPeriod), > currentDate); > this.chosenTickers = ((GenomeMeaning)GO.BestGenome.Meaning).Tickers; > this.chosenTickersPortfolioWeights = > ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights; > > } > //else it will be buyed again the previous optimized portfolio > //that's it the actual chosenTickers member > } > > protected void oneHourAfterMarketCloseEventHandler_updatePrices() > { > //min price for minimizing commission amount > //according to IB Broker's commission scheme > this.minPriceForMinimumCommission = > this.account.CashAmount/(this.numberOfTickersToBeChosen*100); > this.maxPriceForMinimumCommission = this.maxPriceForMinimumCommission; > //just to avoid warning message > } > > /// <summary> > /// Handles a "One hour after market close" event. > /// </summary> > /// <param name="sender"></param> > /// <param name="eventArgs"></param> > public override void OneHourAfterMarketCloseEventHandler( > Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) > { > this.seedForRandomGenerator++; > this.orders.Clear(); > //this.oneHourAfterMarketCloseEventHandler_updatePrices(); > if(this.numDaysElapsedSinceLastOptimization == > this.numDaysBetweenEachOptimization - 1) > { > >this.setTickers(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime, false); > //sets tickers to be chosen at next Market Open event > this.numDaysElapsedSinceLastOptimization = 0; > } > else > { > this.numDaysElapsedSinceLastOptimization++; > } > > } > > #endregion > > } >} > > > >------------------------------------------------------- >This SF.net email is sponsored by: Splunk Inc. Do you grep through log files >for problems? Stop! Download the new AJAX search engine that makes >searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! >http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click >_______________________________________________ >Quantproject-developers mailing list >Qua...@li... >https://lists.sourceforge.net/lists/listinfo/quantproject-developers |
|
From: Marco M. <mi...@us...> - 2005-12-28 23:30:13
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27824/b7_Scripts Modified Files: Scripts.prjx Log Message: Updated #develop project files Index: Scripts.prjx =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/Scripts.prjx,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Scripts.prjx 20 Dec 2005 19:50:52 -0000 1.16 --- Scripts.prjx 28 Dec 2005 23:30:04 -0000 1.17 *************** *** 82,85 **** --- 82,87 ---- <File name=".\WalkForwardTesting\WalkForwardMultiOneRank\ReportDebugger\WFMultiOneRankDebugInSampleForm.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> <File name=".\WalkForwardTesting\WalkForwardMultiOneRank\ReportDebugger\WFMultiOneRankRunInSampleDebug.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\TickerSelectionTesting\TestingOTCTypes\EndOfDayTimerHandlerOTCTypes.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\TickerSelectionTesting\TestingOTCTypes\RunEfficientOTCTypes.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> </Contents> <References> |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27724/b7_Scripts/TickerSelectionTesting Modified Files: RunTestOptimizedCTOPortfolio.cs RunTestOptimizedCTCPortfolio.cs RunEfficientPortfolio.cs RunEfficientCTOPortfolio.cs RunEfficientCTCPortfolio.cs GenomeManagerForEfficientCTOPortfolio.cs GenomeManagerForEfficientCTCPortfolio.cs EndOfDayTimerHandlerCTO.cs EndOfDayTimerHandlerCTCTest.cs EndOfDayTimerHandlerCTC.cs EndOfDayTimerHandler.cs Log Message: Updated script files for the efficient portfolio Index: RunTestOptimizedCTOPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunTestOptimizedCTOPortfolio.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** RunTestOptimizedCTOPortfolio.cs 18 Sep 2005 21:13:36 -0000 1.9 --- RunTestOptimizedCTOPortfolio.cs 28 Dec 2005 23:29:39 -0000 1.10 *************** *** 69,73 **** numDaysBetweenEachOptimization) { ! this.ScriptName = "TestOptimizedCTOPortfolio"; } --- 69,74 ---- numDaysBetweenEachOptimization) { ! //this.ScriptName = "TestOptimizedCTOPortfolio"; ! this.ScriptName = "TestOptimizedCTOWeightedPortfolio"; } Index: EndOfDayTimerHandler.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandler.cs,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** EndOfDayTimerHandler.cs 8 Nov 2005 18:36:48 -0000 1.18 --- EndOfDayTimerHandler.cs 28 Dec 2005 23:29:40 -0000 1.19 *************** *** 63,67 **** //backtest, for minimizing commission amount, //according to broker's commission scheme ! protected double minPriceForMinimumCommission = 0; protected double maxPriceForMinimumCommission = 500; --- 63,67 ---- //backtest, for minimizing commission amount, //according to broker's commission scheme ! protected double minPriceForMinimumCommission = 30; protected double maxPriceForMinimumCommission = 500; *************** *** 224,228 **** //add cash first if(this.orders.Count == 0 && this.account.Transactions.Count == 0) ! this.account.AddCash(17000); if(this.openPositions_allChosenTickersQuotedAtCurrentDate()) //all tickers have quotes at the current date, so orders can be filled --- 224,228 ---- //add cash first if(this.orders.Count == 0 && this.account.Transactions.Count == 0) ! this.account.AddCash(30000); if(this.openPositions_allChosenTickersQuotedAtCurrentDate()) //all tickers have quotes at the current date, so orders can be filled Index: RunEfficientCTCPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientCTCPortfolio.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** RunEfficientCTCPortfolio.cs 17 Nov 2005 21:37:19 -0000 1.12 --- RunEfficientCTCPortfolio.cs 28 Dec 2005 23:29:39 -0000 1.13 *************** *** 60,63 **** --- 60,64 ---- { protected int numDayOfPortfolioLife; + protected int numDaysWithNoPositions; protected int numDaysForReturnCalculation; protected double maxAcceptableCloseToCloseDrawdown; *************** *** 69,73 **** int populationSizeForGeneticOptimizer, string benchmark, DateTime startDate, DateTime endDate, ! int numDaysOfPortfolioLife, int numDaysForReturnCalculation, double targetReturn, PortfolioType portfolioType, double maxAcceptableCloseToCloseDrawdown, --- 70,75 ---- int populationSizeForGeneticOptimizer, string benchmark, DateTime startDate, DateTime endDate, ! int numDaysOfPortfolioLife, int numDaysForReturnCalculation, ! int numDaysWithNoPositions, double targetReturn, PortfolioType portfolioType, double maxAcceptableCloseToCloseDrawdown, *************** *** 80,87 **** portfolioType, maxRunningHours) { ! this.ScriptName = "CloseToCloseScriptsDiscontinuos"; //this.ScriptName = "CloseToCloseScriptsDiscontinuosWithCoeff"; this.numDayOfPortfolioLife = numDaysOfPortfolioLife; this.numDaysForReturnCalculation = numDaysForReturnCalculation; this.maxAcceptableCloseToCloseDrawdown = maxAcceptableCloseToCloseDrawdown; this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; --- 82,90 ---- portfolioType, maxRunningHours) { ! this.ScriptName = "CloseToCloseScriptsDiscontinuosWithSharpe"; //this.ScriptName = "CloseToCloseScriptsDiscontinuosWithCoeff"; this.numDayOfPortfolioLife = numDaysOfPortfolioLife; this.numDaysForReturnCalculation = numDaysForReturnCalculation; + this.numDaysWithNoPositions = numDaysWithNoPositions; this.maxAcceptableCloseToCloseDrawdown = maxAcceptableCloseToCloseDrawdown; this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; *************** *** 98,101 **** --- 101,105 ---- this.populationSizeForGeneticOptimizer, this.benchmark, this.numDayOfPortfolioLife, this.numDaysForReturnCalculation, + this.numDaysWithNoPositions, this.targetReturn, this.portfolioType, this.maxAcceptableCloseToCloseDrawdown, Index: RunTestOptimizedCTCPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunTestOptimizedCTCPortfolio.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** RunTestOptimizedCTCPortfolio.cs 17 Nov 2005 21:37:19 -0000 1.8 --- RunTestOptimizedCTCPortfolio.cs 28 Dec 2005 23:29:39 -0000 1.9 *************** *** 66,70 **** int populationSizeForGeneticOptimizer, string benchmark, DateTime endDate, ! int numDaysOfPortfolioLife, int numDaysForReturnCalculation, double targetReturn, PortfolioType portfolioType, double maxAcceptableCloseToCloseDrawdown, --- 66,71 ---- int populationSizeForGeneticOptimizer, string benchmark, DateTime endDate, ! int numDaysOfPortfolioLife, int numDaysForReturnCalculation, ! int numDaysWithNoPositions, double targetReturn, PortfolioType portfolioType, double maxAcceptableCloseToCloseDrawdown, *************** *** 75,79 **** populationSizeForGeneticOptimizer, benchmark, endDate.AddDays(-numDaysForOptimizationPeriod), endDate, ! numDaysOfPortfolioLife - 1, numDaysForReturnCalculation, targetReturn, portfolioType, maxAcceptableCloseToCloseDrawdown, --- 76,81 ---- populationSizeForGeneticOptimizer, benchmark, endDate.AddDays(-numDaysForOptimizationPeriod), endDate, ! numDaysOfPortfolioLife, numDaysForReturnCalculation, ! numDaysWithNoPositions, targetReturn, portfolioType, maxAcceptableCloseToCloseDrawdown, *************** *** 83,87 **** } ! protected override void run_initializeEndOfDayTimerHandler() { --- 85,89 ---- } ! protected override void run_initializeEndOfDayTimerHandler() { *************** *** 93,96 **** --- 95,99 ---- this.numDayOfPortfolioLife, this.numDaysForReturnCalculation, + this.numDaysWithNoPositions, this.targetReturn, this.portfolioType, this.maxAcceptableCloseToCloseDrawdown, Index: GenomeManagerForEfficientCTCPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/GenomeManagerForEfficientCTCPortfolio.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** GenomeManagerForEfficientCTCPortfolio.cs 17 Nov 2005 21:37:19 -0000 1.11 --- GenomeManagerForEfficientCTCPortfolio.cs 28 Dec 2005 23:29:39 -0000 1.12 *************** *** 41,45 **** --- 41,58 ---- { private int numDaysForReturnCalculation; + private double shiftedPortfolioRateOfReturn; + private float[] shiftedPortfolioRatesOfReturn; + //private double shiftedPortfolioVariance; + //rate of return and variance of portfolio + //shifted ahead of numDaysForReturnCalculation + /// <summary> + /// Rates of returns of the portfolio shifted ahead of numDaysForReturnCalculation + /// </summary> + public float[] ShiftedPortfolioRatesOfReturn + { + get{return this.shiftedPortfolioRatesOfReturn;} + } + public GenomeManagerForEfficientCTCPortfolio(DataTable setOfInitialTickers, DateTime firstQuoteDate, *************** *** 90,117 **** protected override float[] getArrayOfRatesOfReturn(string ticker) { ! /* ! float[] returnValue = null; ! Quotes tickerQuotes = new Quotes(ticker, this.firstQuoteDate, this.lastQuoteDate); ! float[] allAdjValues = ExtendedDataTable.GetArrayOfFloatFromColumn(tickerQuotes, "quAdjustedClose"); ! returnValue = new float[allAdjValues.Length/this.numDaysForReturnCalculation + 1]; ! int i = 0; //index for ratesOfReturns array ! int lastIdxAccessed = 0; ! for(int idx = 0; ! (idx + this.numDaysForReturnCalculation) < allAdjValues.Length; ! idx += this.numDaysForReturnCalculation ) ! { ! if(idx-lastIdxAccessed>numDaysForReturnCalculation || idx == 0) ! //there is a discontinuity, as wanted ! { ! returnValue[i] = (allAdjValues[idx+this.numDaysForReturnCalculation]/ ! allAdjValues[idx] - 1); ! lastIdxAccessed = idx; ! i++; ! } ! } ! this.numberOfExaminedReturns = returnValue.Length; ! ! return returnValue; ! */ float[] returnValue = null; returnValue = --- 103,108 ---- protected override float[] getArrayOfRatesOfReturn(string ticker) { ! this.calculateShiftedRateOfReturn(ticker); ! float[] returnValue = null; returnValue = *************** *** 156,167 **** } */ - //sharpe ratio as fitness - /* protected override double getFitnessValue_calculate() { ! return this.RateOfReturn/Math.Sqrt(this.Variance); } ! */ } --- 147,177 ---- } */ + private void calculateShiftedRateOfReturn(string ticker) + { + try + { + float[] closeToCloseRatios = Quotes.GetArrayOfCloseToCloseRatios(ticker, this.firstQuoteDate, + this.lastQuoteDate, + this.numDaysForReturnCalculation, + this.numDaysForReturnCalculation); + this.shiftedPortfolioRatesOfReturn = closeToCloseRatios; + this.shiftedPortfolioRateOfReturn = + BasicFunctions.SimpleAverage(closeToCloseRatios); + //this.shiftedPortfolioVariance = + //BasicFunctions.Variance(closeToCloseRatios); + } + catch(Exception ex) + { + ex = ex; + } + } protected override double getFitnessValue_calculate() { ! return (this.RateOfReturn/Math.Sqrt(this.Variance))* ! -this.shiftedPortfolioRateOfReturn * ! -this.ShiftedPortfolioRatesOfReturn[this.ShiftedPortfolioRatesOfReturn.Length -1]; } ! } Index: GenomeManagerForEfficientCTOPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/GenomeManagerForEfficientCTOPortfolio.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** GenomeManagerForEfficientCTOPortfolio.cs 17 Nov 2005 21:37:19 -0000 1.15 --- GenomeManagerForEfficientCTOPortfolio.cs 28 Dec 2005 23:29:39 -0000 1.16 *************** *** 96,105 **** } */ ! ! // protected override double getFitnessValue_calculate() ! // { ! // return this.RateOfReturn/Math.Sqrt(this.Variance); ! // } ! } --- 96,105 ---- } */ ! /* ! protected override double getFitnessValue_calculate() ! { ! return this.RateOfReturn/Math.Sqrt(this.Variance); ! } ! */ } Index: EndOfDayTimerHandlerCTO.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerCTO.cs,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** EndOfDayTimerHandlerCTO.cs 8 Nov 2005 18:36:48 -0000 1.21 --- EndOfDayTimerHandlerCTO.cs 28 Dec 2005 23:29:40 -0000 1.22 *************** *** 65,69 **** this.seedForRandomGenerator = ConstantsProvider.SeedForRandomGenerator; } ! /// <summary> --- 65,110 ---- this.seedForRandomGenerator = ConstantsProvider.SeedForRandomGenerator; } ! ! private double marketOpenEventHandler_currCombinationHasLost_getValue(ExtendedDateTime extendedDateTime) ! { ! double returnValue = 0.0; ! string signedTicker; ! string unsignedTicker; ! double tickerMarketValue; ! for(int i = 0; i<this.chosenTickers.Length; i++) ! { ! signedTicker = this.chosenTickers[i]; ! unsignedTicker = ! GenomeManagerForEfficientPortfolio.GetCleanTickerCode(signedTicker); ! tickerMarketValue = ! HistoricalDataProvider.GetAdjustedMarketValue(unsignedTicker,extendedDateTime); ! if(signedTicker == unsignedTicker) ! //long position for the ticker ! returnValue += this.chosenTickersPortfolioWeights[i]*tickerMarketValue; ! else//short position for the ticker ! returnValue -= this.chosenTickersPortfolioWeights[i]*tickerMarketValue; ! } ! return returnValue; ! ! } ! ! private bool marketOpenEventHandler_currCombinationHasLost() ! { ! bool returnValue = false; ! IndexBasedEndOfDayTimer currentTimer = (IndexBasedEndOfDayTimer)this.account.EndOfDayTimer; ! ExtendedDateTime now = ! new ExtendedDateTime(currentTimer.GetCurrentTime().DateTime, ! BarComponent.Open); ! ExtendedDateTime previousClose = ! new ExtendedDateTime(currentTimer.GetPreviousDateTime(), ! BarComponent.Close); ! double currentCombinationValue_Now = ! this.marketOpenEventHandler_currCombinationHasLost_getValue(now); ! double currentCombinationValue_AtPreviousMarketClose = ! this.marketOpenEventHandler_currCombinationHasLost_getValue(previousClose); ! if(currentCombinationValue_Now < currentCombinationValue_AtPreviousMarketClose) ! returnValue = true; ! return returnValue; ! } /// <summary> *************** *** 75,81 **** Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! //temporarily the if condition ! //if(this.numDaysElapsedSinceLastOptimization == 0) ! this.openPositions(); } --- 116,130 ---- Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! if(this.orders.Count == 0 && this.account.Transactions.Count == 0) ! this.account.AddCash(30000); ! bool allTickerHasBeenChosen = true; ! for( int i = 0; i<this.chosenTickers.Length; i++) ! { ! if(this.chosenTickers[i] == null) ! allTickerHasBeenChosen = false; ! } ! if(allTickerHasBeenChosen && ! this.marketOpenEventHandler_currCombinationHasLost()) ! this.openPositions(); } *************** *** 84,93 **** Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! ! //temporarily ! //if(this.numDaysElapsedSinceLastOptimization == ! // this.numDaysBetweenEachOptimization) ! this.closePositions(); ! } --- 133,137 ---- Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! this.closePositions(); } *************** *** 98,123 **** protected DataTable getSetOfTickersToBeOptimized(DateTime currentDate) { - /* - SelectorByAverageRawOpenPrice selectorByOpenPrice = - new SelectorByAverageRawOpenPrice(this.tickerGroupID, false, - currentDate.AddDays(-this.numDaysForLiquidity), currentDate, - this.numberOfEligibleTickers, this.minPriceForMinimumCommission, - this.maxPriceForMinimumCommission, 0, 2); - DataTable tickersByPrice = selectorByOpenPrice.GetTableOfSelectedTickers(); - */ SelectorByGroup temporizedGroup = new SelectorByGroup(this.tickerGroupID, currentDate); ! SelectorByOpenCloseCorrelationToBenchmark lessCorrelatedFromTemporizedGroup = ! new SelectorByOpenCloseCorrelationToBenchmark(temporizedGroup.GetTableOfSelectedTickers(), this.benchmark,true, currentDate.AddDays(-this.numDaysForOptimizationPeriod ), currentDate, ! this.numberOfEligibleTickers); ! this.eligibleTickers = lessCorrelatedFromTemporizedGroup.GetTableOfSelectedTickers(); SelectorByQuotationAtEachMarketDay quotedAtEachMarketDayFromEligible = new SelectorByQuotationAtEachMarketDay( this.eligibleTickers, false, currentDate.AddDays(-this.numDaysForOptimizationPeriod), ! currentDate, this.numberOfEligibleTickers, this.benchmark); //SelectorByWinningOpenToClose winners = // new SelectorByWinningOpenToClose(quotedAtEachMarketDayFromMostLiquid.GetTableOfSelectedTickers(), --- 142,172 ---- protected DataTable getSetOfTickersToBeOptimized(DateTime currentDate) { SelectorByGroup temporizedGroup = new SelectorByGroup(this.tickerGroupID, currentDate); ! ! SelectorByLiquidity mostLiquidFromTemporized = ! new SelectorByLiquidity(temporizedGroup.GetTableOfSelectedTickers(), ! false, currentDate.AddDays(-this.numDaysForOptimizationPeriod), ! currentDate, this.numberOfEligibleTickers); ! ! SelectorByAverageRawOpenPrice selectorByOpenPriceFromMostLiquid = ! new SelectorByAverageRawOpenPrice(mostLiquidFromTemporized.GetTableOfSelectedTickers(), false, ! currentDate.AddDays(-10), currentDate, ! this.numberOfEligibleTickers, this.minPriceForMinimumCommission, ! this.maxPriceForMinimumCommission, 0, 10); ! ! SelectorByOpenCloseCorrelationToBenchmark lessCorrelatedFromSelectedByPrice = ! new SelectorByOpenCloseCorrelationToBenchmark(selectorByOpenPriceFromMostLiquid.GetTableOfSelectedTickers(), this.benchmark,true, currentDate.AddDays(-this.numDaysForOptimizationPeriod ), currentDate, ! this.numberOfEligibleTickers/2); ! this.eligibleTickers = lessCorrelatedFromSelectedByPrice.GetTableOfSelectedTickers(); SelectorByQuotationAtEachMarketDay quotedAtEachMarketDayFromEligible = new SelectorByQuotationAtEachMarketDay( this.eligibleTickers, false, currentDate.AddDays(-this.numDaysForOptimizationPeriod), ! currentDate, this.numberOfEligibleTickers/2, this.benchmark); ! //SelectorByWinningOpenToClose winners = // new SelectorByWinningOpenToClose(quotedAtEachMarketDayFromMostLiquid.GetTableOfSelectedTickers(), *************** *** 131,135 **** --- 180,186 ---- // currentDate, this.numberOfEligibleTickers/2); return quotedAtEachMarketDayFromEligible.GetTableOfSelectedTickers(); + //return mostLiquidFromQuotedAtEachMarketDay.GetTableOfSelectedTickers(); //return lessCorrelated.GetTableOfSelectedTickers(); + //return selectorByOpenPriceFromMostLiquid.GetTableOfSelectedTickers(); } Index: RunEfficientPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientPortfolio.cs,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** RunEfficientPortfolio.cs 27 Sep 2005 22:17:51 -0000 1.17 --- RunEfficientPortfolio.cs 28 Dec 2005 23:29:39 -0000 1.18 *************** *** 180,184 **** protected virtual void run_initializeAccount() { ! //default account with no commissions this.account = new Account( this.scriptName , this.endOfDayTimer , new HistoricalEndOfDayDataStreamer( this.endOfDayTimer , --- 180,184 ---- protected virtual void run_initializeAccount() { ! //default account with no commissions and no slippage calculation this.account = new Account( this.scriptName , this.endOfDayTimer , new HistoricalEndOfDayDataStreamer( this.endOfDayTimer , Index: EndOfDayTimerHandlerCTC.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerCTC.cs,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** EndOfDayTimerHandlerCTC.cs 17 Nov 2005 21:37:19 -0000 1.18 --- EndOfDayTimerHandlerCTC.cs 28 Dec 2005 23:29:40 -0000 1.19 *************** *** 46,51 **** protected int numDaysOfPortfolioLife; protected int numDaysForReturnCalculation; ! protected int daysCounter; ! protected int daysWithNoPositions; protected double maxAcceptableCloseToCloseDrawdown; protected bool stopLossConditionReached; --- 46,52 ---- protected int numDaysOfPortfolioLife; protected int numDaysForReturnCalculation; ! protected int numDaysWithNoPositions; ! protected int daysCounterWithPositions; ! protected int daysCounterWithNoPositions; protected double maxAcceptableCloseToCloseDrawdown; protected bool stopLossConditionReached; *************** *** 63,66 **** --- 64,68 ---- int numDaysOfPortfolioLife, int numDaysForReturnCalculation, + int numDaysWithNoPositions, double targetReturn, PortfolioType portfolioType, double maxAcceptableCloseToCloseDrawdown, *************** *** 75,79 **** this.numDaysOfPortfolioLife = numDaysOfPortfolioLife; this.numDaysForReturnCalculation = numDaysForReturnCalculation; ! this.daysCounter = 0; this.maxAcceptableCloseToCloseDrawdown = maxAcceptableCloseToCloseDrawdown; this.stopLossConditionReached = false; --- 77,83 ---- this.numDaysOfPortfolioLife = numDaysOfPortfolioLife; this.numDaysForReturnCalculation = numDaysForReturnCalculation; ! this.numDaysWithNoPositions = numDaysWithNoPositions; ! this.daysCounterWithPositions = 0; ! this.daysCounterWithNoPositions = 0; this.maxAcceptableCloseToCloseDrawdown = maxAcceptableCloseToCloseDrawdown; this.stopLossConditionReached = false; *************** *** 111,116 **** //portfolio is not empty { ! this.daysCounter++; ! if(this.daysCounter == this.numDaysOfPortfolioLife || this.stopLossConditionReached) //num days of portfolio life or --- 115,120 ---- //portfolio is not empty { ! this.daysCounterWithPositions++; ! if(this.daysCounterWithPositions == this.numDaysOfPortfolioLife || this.stopLossConditionReached) //num days of portfolio life or *************** *** 118,125 **** { this.closePositions(); ! this.daysCounter = 0; //positionsJustClosed = true; } } //old // if(this.account.Portfolio.Count == 0 && --- 122,141 ---- { this.closePositions(); ! this.daysCounterWithPositions = 0; //positionsJustClosed = true; } } + else//portfolio is empty + { + this.daysCounterWithNoPositions++; + if(this.daysCounterWithNoPositions == this.numDaysWithNoPositions || + this.Account.Transactions.Count <= 1) + { + this.openPositions(); + this.daysCounterWithNoPositions = 0; + } + } + } + //old // if(this.account.Portfolio.Count == 0 && *************** *** 131,147 **** // this.daysCounter = 0; // } ! ! if(this.account.Portfolio.Count == 0) ! //portfolio is empty ! { ! this.daysWithNoPositions++; ! if(this.daysWithNoPositions>this.numDaysOfPortfolioLife) ! { ! this.openPositions(); ! this.daysWithNoPositions = 0; ! } ! } ! } ! #endregion --- 147,151 ---- // this.daysCounter = 0; // } ! #endregion *************** *** 153,173 **** currentDate); ! SelectorByCloseToCloseCorrelationToBenchmark lessCorrelatedFromTemporized = ! new SelectorByCloseToCloseCorrelationToBenchmark(temporizedGroup.GetTableOfSelectedTickers(), this.benchmark,true, currentDate.AddDays(-this.numDaysForOptimizationPeriod ), currentDate, ! this.numberOfEligibleTickers, this.numDaysForReturnCalculation); ! ! ! ! ! this.eligibleTickers = lessCorrelatedFromTemporized.GetTableOfSelectedTickers(); ! SelectorByQuotationAtEachMarketDay quotedAtEachMarketDayFromEligible = ! new SelectorByQuotationAtEachMarketDay(this.eligibleTickers, ! false, currentDate.AddDays(-this.numDaysForOptimizationPeriod),currentDate, ! this.numberOfEligibleTickers, this.benchmark); ! return quotedAtEachMarketDayFromEligible.GetTableOfSelectedTickers(); } --- 157,182 ---- currentDate); ! SelectorByQuotationAtEachMarketDay quotedAtEachMarketFromTemporized = ! new SelectorByQuotationAtEachMarketDay(temporizedGroup.GetTableOfSelectedTickers(), ! false, currentDate.AddDays(-this.numDaysForOptimizationPeriod),currentDate, ! this.numberOfEligibleTickers, this.benchmark); ! ! this.eligibleTickers = quotedAtEachMarketFromTemporized.GetTableOfSelectedTickers(); ! ! SelectorByCloseToCloseCorrelationToBenchmark lessCorrelatedFromEligible = ! new SelectorByCloseToCloseCorrelationToBenchmark(this.eligibleTickers, this.benchmark,true, currentDate.AddDays(-this.numDaysForOptimizationPeriod ), currentDate, ! this.numberOfEligibleTickers/2, this.numDaysForReturnCalculation); ! SelectorByAbsolutePerformance mostQuietFromLessCorrelated = ! new SelectorByAbsolutePerformance(lessCorrelatedFromEligible.GetTableOfSelectedTickers(), ! true,currentDate.AddDays(-this.numDaysForOptimizationPeriod ), ! currentDate, ! this.numberOfEligibleTickers/4, ! 0.01f, 0.10f); ! ! return mostQuietFromLessCorrelated.GetTableOfSelectedTickers(); } *************** *** 228,235 **** // //it sets tickers to be chosen at next close // } ! this.orders.Clear(); //this.oneHourAfterMarketCloseEventHandler_updatePrices(); if(this.numDaysElapsedSinceLastOptimization == ! this.numDaysBetweenEachOptimization - 1) { this.setTickers(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime, false); --- 237,248 ---- // //it sets tickers to be chosen at next close // } ! //this.oneHourAfterMarketCloseEventHandler_updatePrices(); + this.numDaysElapsedSinceLastOptimization++; + this.orders.Clear(); if(this.numDaysElapsedSinceLastOptimization == ! this.numDaysBetweenEachOptimization) ! //num days without optimization has elapsed or ! //just money has been added to the account { this.setTickers(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime, false); *************** *** 237,244 **** this.numDaysElapsedSinceLastOptimization = 0; } ! else ! { ! this.numDaysElapsedSinceLastOptimization++; ! } } #endregion --- 250,254 ---- this.numDaysElapsedSinceLastOptimization = 0; } ! } #endregion Index: RunEfficientCTOPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientCTOPortfolio.cs,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** RunEfficientCTOPortfolio.cs 17 Nov 2005 21:37:19 -0000 1.24 --- RunEfficientCTOPortfolio.cs 28 Dec 2005 23:29:39 -0000 1.25 *************** *** 37,40 **** --- 37,41 ---- using QuantProject.Business.Timing; using QuantProject.Business.Financial.Accounting.Commissions; + using QuantProject.Business.Financial.Accounting.Slippage; using QuantProject.Data.DataProviders; using QuantProject.Data.Selectors; *************** *** 74,93 **** //this.ScriptName = "OpenCloseScriptsSharpeRatio"; this.ScriptName = "OpenCloseScriptsWithCoeff"; this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; } - #region auxiliary overriden methods for Run ! /* delete remark delimitations for having ib commission protected override void run_initializeAccount() { ! this.account = new Account( this.ScriptName , this.endOfDayTimer , ! new HistoricalEndOfDayDataStreamer( this.endOfDayTimer , ! this.historicalQuoteProvider ) , ! new HistoricalEndOfDayOrderExecutor( this.endOfDayTimer , ! this.historicalQuoteProvider ), new IBCommissionManager()); } ! */ protected override void run_initializeEndOfDayTimerHandler() --- 75,99 ---- //this.ScriptName = "OpenCloseScriptsSharpeRatio"; this.ScriptName = "OpenCloseScriptsWithCoeff"; + //this.ScriptName = "OpenCloseScripts"; this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; } ! // delete remark delimitations for having ib commission ! // and a fixed percentage calculation of slippage protected override void run_initializeAccount() { ! this.account = new Account(this.ScriptName, ! this.endOfDayTimer , ! new HistoricalEndOfDayDataStreamer(this.endOfDayTimer , ! this.historicalQuoteProvider ) , ! new HistoricalEndOfDayOrderExecutor(this.endOfDayTimer , ! this.historicalQuoteProvider, ! new FixedPercentageSlippageManager(this.historicalQuoteProvider, ! this.endOfDayTimer,0.08)), ! new IBCommissionManager()); } ! protected override void run_initializeEndOfDayTimerHandler() *************** *** 129,133 **** this.endOfDayTimerHandler.OneHourAfterMarketCloseEventHandler ); } ! #endregion //necessary far calling RunEfficientPortfolio.Run() --- 135,140 ---- this.endOfDayTimerHandler.OneHourAfterMarketCloseEventHandler ); } ! ! //necessary far calling RunEfficientPortfolio.Run() Index: EndOfDayTimerHandlerCTCTest.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerCTCTest.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** EndOfDayTimerHandlerCTCTest.cs 17 Nov 2005 21:37:19 -0000 1.5 --- EndOfDayTimerHandlerCTCTest.cs 28 Dec 2005 23:29:40 -0000 1.6 *************** *** 55,58 **** --- 55,59 ---- int numDaysOfPortfolioLife, int numDaysForReturnCalculation, + int numDaysWithNoPositions, double targetReturn, PortfolioType portfolioType, double maxAcceptableCloseToCloseDrawdown, *************** *** 66,69 **** --- 67,71 ---- numDaysOfPortfolioLife, numDaysForReturnCalculation, + numDaysWithNoPositions, targetReturn, portfolioType, maxAcceptableCloseToCloseDrawdown, |
|
From: Marco M. <mi...@us...> - 2005-12-28 23:28:04
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataTables In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27459/b3_Data/DataTables Modified Files: Quotes.cs Log Message: Selection of couples of tickers by correlation coefficient is now much more efficient. Index: Quotes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataTables/Quotes.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Quotes.cs 20 Dec 2005 19:33:12 -0000 1.20 --- Quotes.cs 28 Dec 2005 23:27:56 -0000 1.21 *************** *** 188,196 **** return tableToReturn; } ! /// <summary> ! /// Returns a table containing the Pearson correlation coefficient of the adjusted close to close ratios /// for any possible couple of tickers contained in the given table, for the specified interval /// </summary> --- 188,211 ---- return tableToReturn; } + + private static void getTickersByAdjCloseToClosePearsonCorrelationCoefficient_setTickersReturns(out float[][] + tickersReturns, DataTable setOfTickers, DateTime firstQuoteDate, DateTime lastQuoteDate) + + { + tickersReturns = new float[setOfTickers.Rows.Count][]; + for(int i = 0; i<setOfTickers.Rows.Count; i++) + { + DataTable tickerQuoteTable = + QuantProject.DataAccess.Tables.Quotes.GetTickerQuotes((string)setOfTickers.Rows[i][0], + firstQuoteDate, + lastQuoteDate); + tickersReturns[i] = + ExtendedDataTable.GetArrayOfFloatFromColumn(tickerQuoteTable,"quAdjustedClose"); ! } ! } /// <summary> ! /// Returns a table containing the Pearson correlation coefficient for the adjusted close values /// for any possible couple of tickers contained in the given table, for the specified interval /// </summary> *************** *** 206,209 **** --- 221,226 ---- setOfTickers.Columns.Add("PearsonCorrelationCoefficient", System.Type.GetType("System.Double")); int initialNumberOfRows = setOfTickers.Rows.Count; + float[][] tickersReturns; + getTickersByAdjCloseToClosePearsonCorrelationCoefficient_setTickersReturns(out tickersReturns, setOfTickers, firstQuoteDate, lastQuoteDate); for(int j=0; j!= initialNumberOfRows; j++) { *************** *** 212,223 **** { string secondTicker = (string)setOfTickers.Rows[i][0]; - DataTable dtFirstTicker = QuantProject.DataAccess.Tables.Quotes.GetTickerQuotes(firstTicker, - firstQuoteDate, - lastQuoteDate); - DataTable dtSecondTicker = QuantProject.DataAccess.Tables.Quotes.GetTickerQuotes(secondTicker, - firstQuoteDate, - lastQuoteDate); DataRow rowToAdd = setOfTickers.NewRow(); rowToAdd[0] = firstTicker; rowToAdd["CorrelatedTicker"] = secondTicker; try --- 229,236 ---- { string secondTicker = (string)setOfTickers.Rows[i][0]; DataRow rowToAdd = setOfTickers.NewRow(); rowToAdd[0] = firstTicker; + rowToAdd["PearsonCorrelationCoefficient"] = -2.0; + //unassigned value for this column rowToAdd["CorrelatedTicker"] = secondTicker; try *************** *** 225,240 **** rowToAdd["PearsonCorrelationCoefficient"] = QuantProject.ADT.Statistics.BasicFunctions.PearsonCorrelationCoefficient( ! ExtendedDataTable.GetArrayOfFloatFromColumn(dtFirstTicker, "quAdjustedCloseToCloseRatio"), ! ExtendedDataTable.GetArrayOfFloatFromColumn(dtSecondTicker, "quAdjustedCloseToCloseRatio")); ! setOfTickers.Rows.Add(rowToAdd); } catch(Exception ex) { ! string notUsed = ex.ToString(); } } } ExtendedDataTable.DeleteRows(setOfTickers, 0, initialNumberOfRows - 1); ! return ExtendedDataTable.CopyAndSort(setOfTickers,"PearsonCorrelationCoefficient", orderByASC); } --- 238,276 ---- rowToAdd["PearsonCorrelationCoefficient"] = QuantProject.ADT.Statistics.BasicFunctions.PearsonCorrelationCoefficient( ! tickersReturns[j],tickersReturns[i]); } catch(Exception ex) { ! ex = ex; ! } ! finally ! { ! setOfTickers.Rows.Add(rowToAdd); } } } ExtendedDataTable.DeleteRows(setOfTickers, 0, initialNumberOfRows - 1); ! //delete initial rows that don't contain correlated ticker and Pearson coeff. ! return ExtendedDataTable.CopyAndSort(setOfTickers,"PearsonCorrelationCoefficient>-2.0", ! "PearsonCorrelationCoefficient", orderByASC); ! } ! ! /// <summary> ! /// Returns a table containing the Pearson correlation coefficient for the adjusted close values ! /// for any possible couple of tickers contained in the given group of tickers, ! /// for the specified interval ! /// </summary> ! public static DataTable GetTickersByAdjCloseToClosePearsonCorrelationCoefficient( bool orderByASC, ! string groupID, ! DateTime firstQuoteDate, ! DateTime lastQuoteDate) ! ! { ! ! DataTable tickersOfGroup = new Tickers_tickerGroups(groupID); ! return GetTickersByAdjCloseToClosePearsonCorrelationCoefficient(orderByASC, ! tickersOfGroup, ! firstQuoteDate, ! lastQuoteDate); } *************** *** 244,250 **** /// </summary> public static DataTable GetTickersByCloseToOpenPearsonCorrelationCoefficient( bool orderByASC, ! DataTable setOfTickers, ! DateTime firstQuoteDate, ! DateTime lastQuoteDate) { --- 280,286 ---- /// </summary> public static DataTable GetTickersByCloseToOpenPearsonCorrelationCoefficient( bool orderByASC, ! DataTable setOfTickers, ! DateTime firstQuoteDate, ! DateTime lastQuoteDate) { |
|
From: Marco M. <mi...@us...> - 2005-12-28 23:28:03
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/Selectors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27459/b3_Data/Selectors Modified Files: SelectorByCloseToCloseLinearCorrelation.cs Log Message: Selection of couples of tickers by correlation coefficient is now much more efficient. Index: SelectorByCloseToCloseLinearCorrelation.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/Selectors/SelectorByCloseToCloseLinearCorrelation.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SelectorByCloseToCloseLinearCorrelation.cs 27 Feb 2005 19:56:07 -0000 1.1 --- SelectorByCloseToCloseLinearCorrelation.cs 28 Dec 2005 23:27:56 -0000 1.2 *************** *** 67,84 **** public DataTable GetTableOfSelectedTickers() { ! this.launchExceptionIfGroupIDIsNotEmpty(); ! return QuantProject.Data.DataTables.Quotes.GetTickersByAdjCloseToClosePearsonCorrelationCoefficient(this.isOrderedInASCMode, ! this.setOfTickersToBeSelected, ! this.firstQuoteDate, ! this.lastQuoteDate); } ! private void launchExceptionIfGroupIDIsNotEmpty() ! { ! if(this.groupID!="") ! { ! throw new Exception("Not implemented: this type of selection works only with few tickers, at the moment"); ! } ! } public void SelectAllTickers() { --- 67,83 ---- public DataTable GetTableOfSelectedTickers() { ! if(this.setOfTickersToBeSelected == null) ! return QuantProject.Data.DataTables.Quotes.GetTickersByAdjCloseToClosePearsonCorrelationCoefficient(this.isOrderedInASCMode, ! this.groupID, ! this.firstQuoteDate, ! this.lastQuoteDate); ! else ! return QuantProject.Data.DataTables.Quotes.GetTickersByAdjCloseToClosePearsonCorrelationCoefficient(this.isOrderedInASCMode, ! this.setOfTickersToBeSelected, ! this.firstQuoteDate, ! this.lastQuoteDate); } ! public void SelectAllTickers() { |
|
From: Marco M. <mi...@us...> - 2005-12-28 23:24:07
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26753/b7_Scripts Modified Files: b7_Scripts.csproj Log Message: Added files for testing optimized OpenToClose genomes in several manners (daily, multiday, OTC - CTO combined, only CTO, etc.) Index: b7_Scripts.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/b7_Scripts.csproj,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** b7_Scripts.csproj 11 Dec 2005 18:21:04 -0000 1.46 --- b7_Scripts.csproj 28 Dec 2005 23:23:59 -0000 1.47 *************** *** 349,352 **** --- 349,362 ---- /> <File + RelPath = "TickerSelectionTesting\TestingOTCTypes\EndOfDayTimerHandlerOTCTypes.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "TickerSelectionTesting\TestingOTCTypes\RunEfficientOTCTypes.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "WalkForwardTesting\IWalkForwardProgressNotifier.cs" SubType = "Code" |
|
From: Marco M. <mi...@us...> - 2005-12-28 23:22:59
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/TestingOTCTypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26303/TestingOTCTypes Added Files: RunEfficientOTCTypes.cs EndOfDayTimerHandlerOTCTypes.cs Log Message: Added files for testing optimized OpenToClose genomes in several manners (daily, multiday, OTC - CTO combined, only CTO, etc.) --- NEW FILE: RunEfficientOTCTypes.cs --- /* QuantProject - Quantitative Finance Library RunEfficientOTCTypes.cs Copyright (C) 2003 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Collections; using System.Data; using QuantProject.ADT; using QuantProject.ADT.Optimizing.Genetic; using QuantProject.ADT.FileManaging; using QuantProject.Business.DataProviders; using QuantProject.Business.Financial.Accounting; using QuantProject.Business.Financial.Accounting.Reporting; using QuantProject.Business.Financial.Instruments; using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Scripting; using QuantProject.Business.Strategies; using QuantProject.Business.Testing; using QuantProject.Business.Timing; using QuantProject.Business.Financial.Accounting.Commissions; using QuantProject.Data.DataProviders; using QuantProject.Data.Selectors; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; using QuantProject.Presentation.Reporting.WindowsForm; using QuantProject.Scripts.WalkForwardTesting.LinearCombination; namespace QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios { /// <summary> /// Script to test OTC daily, OTC multiday and OTC - CTO /// all together with one optimization and 3 accounts (each for /// each type of strategy) /// </summary> [Serializable] public class RunEfficientOTCTypes : RunEfficientPortfolio { protected int numDaysBetweenEachOptimization; private Account[] accounts; public RunEfficientOTCTypes(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, int generationNumberForGeneticOptimizer, int populationSizeForGeneticOptimizer, string benchmark, DateTime startDate, DateTime endDate, double targetReturn, PortfolioType portfolioType, double maxRunningHours, int numDaysBetweenEachOptimization): base(tickerGroupID, numberOfEligibleTickers, numberOfTickersToBeChosen, numDaysForOptimizationPeriod, generationNumberForGeneticOptimizer, populationSizeForGeneticOptimizer, benchmark, startDate, endDate, targetReturn, portfolioType, maxRunningHours) { this.ScriptName = "OTC_Types"; this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; this.accounts = new Account[4]; } #region auxiliary overriden methods for Run protected override void run_initializeAccount() { for(int i = 0; i<this.accounts.Length; i++) { this.accounts[i] = new Account( this.ScriptName, this.endOfDayTimer , new HistoricalEndOfDayDataStreamer( this.endOfDayTimer , this.historicalQuoteProvider ) , new HistoricalEndOfDayOrderExecutor( this.endOfDayTimer , this.historicalQuoteProvider )); } } protected override void run_initializeEndOfDayTimerHandler() { this.endOfDayTimerHandler = new EndOfDayTimerHandlerOTCTypes(this.tickerGroupID, this.numberOfEligibleTickers, this.numberOfTickersToBeChosen, this.numDaysForOptimizationPeriod, this.generationNumberForGeneticOptimizer, this.populationSizeForGeneticOptimizer, this.benchmark, this.targetReturn, this.portfolioType, this.numDaysBetweenEachOptimization, this.accounts); } protected override void run_initializeHistoricalQuoteProvider() { //this.historicalQuoteProvider = new HistoricalRawQuoteProvider(); this.historicalQuoteProvider = new HistoricalAdjustedQuoteProvider(); } protected override void run_addEventHandlers() { this.endOfDayTimer.MarketOpen += new MarketOpenEventHandler( this.endOfDayTimerHandler.MarketOpenEventHandler); this.endOfDayTimer.MarketClose += new MarketCloseEventHandler( this.endOfDayTimerHandler.MarketCloseEventHandler); this.endOfDayTimer.MarketClose += new MarketCloseEventHandler( this.checkDateForReport); this.endOfDayTimer.OneHourAfterMarketClose += new OneHourAfterMarketCloseEventHandler( this.endOfDayTimerHandler.OneHourAfterMarketCloseEventHandler ); } #endregion //necessary far calling RunEfficientPortfolio.Run() //in classes that inherit from this class public override void Run() { base.Run(); } public override void SaveScriptResults() { string fileName = "From"+this.numberOfEligibleTickers + "OptDays" + this.numDaysForOptimizationPeriod + "Portfolio" + this.numberOfTickersToBeChosen + "GenNum" + this.generationNumberForGeneticOptimizer + "PopSize" + this.populationSizeForGeneticOptimizer + "Target" + Convert.ToString(this.targetReturn) + Convert.ToString(this.portfolioType); string dirNameWhereToSaveAccounts = System.Configuration.ConfigurationSettings.AppSettings["AccountsArchive"] + "\\" + this.ScriptName + "\\"; string dirNameWhereToSaveTransactions = System.Configuration.ConfigurationSettings.AppSettings["TransactionsArchive"] + "\\" + this.ScriptName + "\\"; string dirNameWhereToSaveBestGenomes = System.Configuration.ConfigurationSettings.AppSettings["GenomesArchive"] + "\\" + this.ScriptName + "\\"; this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveAccounts); this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveTransactions); this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveBestGenomes); for(int i = 0; i<this.accounts.Length; i++) { ObjectArchiver.Archive(accounts[i], dirNameWhereToSaveAccounts + fileName + "#" + i.ToString() + ".qPa"); ObjectArchiver.Archive(this.accounts[i].Transactions, dirNameWhereToSaveTransactions + fileName + "#" + i.ToString() + ".qPt"); } OptimizationOutput optimizationOutput = new OptimizationOutput(); foreach(GenomeRepresentation genomeRepresentation in this.endOfDayTimerHandler.BestGenomes) optimizationOutput.Add(genomeRepresentation); ObjectArchiver.Archive(optimizationOutput, dirNameWhereToSaveBestGenomes + fileName + ".bgn"); this.endOfDayTimer.Stop(); } } } --- NEW FILE: EndOfDayTimerHandlerOTCTypes.cs --- /* QuantProject - Quantitative Finance Library EndOfDayTimerHandlerOTCTypes.cs Copyright (C) 2003 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 System.Collections; using QuantProject.ADT; using QuantProject.Business.Financial.Accounting; using QuantProject.Business.Financial.Instruments; using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Timing; using QuantProject.Data.DataProviders; using QuantProject.Data.Selectors; using QuantProject.ADT.Optimizing.Genetic; namespace QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios { /// <summary> /// Implements MarketOpenEventHandler, /// MarketCloseEventHandler and OneHourAfterMarketCloseEventHandler /// These handlers run all the /// OTC strategy types after a common optimization, for testing purposes /// </summary> [Serializable] public class EndOfDayTimerHandlerOTCTypes : EndOfDayTimerHandler { private int numDaysBetweenEachOptimization; private int numDaysElapsedSinceLastOptimization; private int seedForRandomGenerator; private Account[] accounts; //private ArrayList[] ordersForAccounts; public EndOfDayTimerHandlerOTCTypes(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, int generationNumberForGeneticOptimizer, int populationSizeForGeneticOptimizer, string benchmark, double targetReturn, PortfolioType portfolioType, int numDaysBetweenEachOptimization, Account[] accounts): base(tickerGroupID, numberOfEligibleTickers, numberOfTickersToBeChosen, numDaysForOptimizationPeriod, accounts[0], generationNumberForGeneticOptimizer, populationSizeForGeneticOptimizer, benchmark, targetReturn, portfolioType) { this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; this.numDaysElapsedSinceLastOptimization = 0; this.seedForRandomGenerator = ConstantsProvider.SeedForRandomGenerator; this.accounts = accounts; //for(int i = 0; i<this.accounts.Length;i++) //ordersForAccounts[i] = new ArrayList(); } // protected override void addChosenTickersToOrderList() // { // for(int i = 0; i<this.accounts.Length; i++) // { // if(i==0)//OTC daily // {} // if(i==1) // {} // if(i==2) // {} // for(int j = 0; j<this.numberOfTickersToBeChosen; j++) // { // string ticker = this.chosenTickersForAccounts[i,j]; // if( ticker != null) // { // this.addOrderForTickerForEachAccount(i, ticker ); // this.lastOrderedTickersForAccounts[i,j] = // GenomeManagerForEfficientPortfolio.GetCleanTickerCode(ticker); // } // } // } // } private void openPositions_openWhenPortfolioIsEmpty(int accountNumber) { if(this.accounts[accountNumber].Portfolio.Count == 0) { foreach(object item in this.orders) this.accounts[accountNumber].AddOrder((Order)item); } } protected override void openPositions() { this.addChosenTickersToOrderList(); for(int i = 0; i<this.accounts.Length; i++) { //add cash first for each account if(this.orders.Count == 0 && this.accounts[i].Transactions.Count == 0) this.accounts[i].AddCash(30000); if(i<=1)//daily classical, and multiday this.openPositions_openWhenPortfolioIsEmpty(i); else if(i==2)//for the CTO OTC { this.closePositions_close(i); foreach(object item in this.orders) this.accounts[i].AddOrder((Order)item); } else if(i==3)//for the CTO, only at night { this.closePositions_close(i); } } } private void closePositions_close(int accountNumber) { string ticker; if(this.accounts[accountNumber].Portfolio.Count >0) { for(int j = 0; j<this.lastOrderedTickers.Length; j++) { ticker = this.lastOrderedTickers[j]; if( ticker != null) { if(this.accounts[accountNumber].Portfolio[ticker]!=null) this.accounts[accountNumber].ClosePosition(ticker); } } } } protected override void closePositions() { for(int i=0; i<this.accounts.Length; i++) { if(i==0)//OTC daily account this.closePositions_close(i); if(i==1)//OTC 2 days { if(this.numDaysElapsedSinceLastOptimization == this.numDaysBetweenEachOptimization - 1) this.closePositions_close(i); } if(i==2)//OTC-CTO { this.closePositions_close(i); if(this.numDaysElapsedSinceLastOptimization < this.numDaysBetweenEachOptimization - 1) //open reverse positions at night { this.reverseSignOfChosenTickers(); this.orders.Clear(); this.addChosenTickersToOrderList(); this.openPositions_openWhenPortfolioIsEmpty(i); this.reverseSignOfChosenTickers(); this.orders.Clear(); } } if(i==3)//CTO, only at night { // this.closePositions_close(i); if(this.numDaysElapsedSinceLastOptimization < this.numDaysBetweenEachOptimization - 1) //open reverse positions at night { this.reverseSignOfChosenTickers(); this.orders.Clear(); this.addChosenTickersToOrderList(); this.openPositions_openWhenPortfolioIsEmpty(i); this.reverseSignOfChosenTickers(); this.orders.Clear(); } } } } private void reverseSignOfChosenTickers() { for(int i = 0; i<this.chosenTickers.Length; i++) { if(this.chosenTickers[i] != null) { if(this.chosenTickers[i].StartsWith("-")) this.chosenTickers[i] = GenomeManagerForEfficientPortfolio.GetCleanTickerCode(this.chosenTickers[i]); else this.chosenTickers[i] = "-" + this.chosenTickers[i]; } } } /// <summary> /// Handles a "Market Open" event. /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> public override void MarketOpenEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { //temporarily the if condition //if(this.numDaysElapsedSinceLastOptimization == 0) this.openPositions(); } public override void MarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { //temporarily //if(this.numDaysElapsedSinceLastOptimization == // this.numDaysBetweenEachOptimization) this.closePositions(); } #region OneHourAfterMarketCloseEventHandler protected DataTable getSetOfTickersToBeOptimized(DateTime currentDate) { /* SelectorByAverageRawOpenPrice selectorByOpenPrice = new SelectorByAverageRawOpenPrice(this.tickerGroupID, false, currentDate.AddDays(-this.numDaysForLiquidity), currentDate, this.numberOfEligibleTickers, this.minPriceForMinimumCommission, this.maxPriceForMinimumCommission, 0, 2); DataTable tickersByPrice = selectorByOpenPrice.GetTableOfSelectedTickers(); */ SelectorByGroup temporizedGroup = new SelectorByGroup(this.tickerGroupID, currentDate); SelectorByOpenCloseCorrelationToBenchmark lessCorrelatedFromTemporizedGroup = new SelectorByOpenCloseCorrelationToBenchmark(temporizedGroup.GetTableOfSelectedTickers(), this.benchmark,true, currentDate.AddDays(-this.numDaysForOptimizationPeriod ), currentDate, this.numberOfEligibleTickers); this.eligibleTickers = lessCorrelatedFromTemporizedGroup.GetTableOfSelectedTickers(); SelectorByQuotationAtEachMarketDay quotedAtEachMarketDayFromEligible = new SelectorByQuotationAtEachMarketDay( this.eligibleTickers, false, currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, this.numberOfEligibleTickers, this.benchmark); //SelectorByWinningOpenToClose winners = // new SelectorByWinningOpenToClose(quotedAtEachMarketDayFromMostLiquid.GetTableOfSelectedTickers(), // false, currentDate.AddDays(-2), // currentDate, this.numberOfEligibleTickers/4); //return winners.GetTableOfSelectedTickers(); //SelectorByOpenCloseCorrelationToBenchmark lessCorrelated = // new SelectorByOpenCloseCorrelationToBenchmark(quotedAtEachMarketDayFromEligible.GetTableOfSelectedTickers(), // this.benchmark, true, // currentDate.AddDays(-this.numDaysForLiquidity), // currentDate, this.numberOfEligibleTickers/2); return quotedAtEachMarketDayFromEligible.GetTableOfSelectedTickers(); //return lessCorrelated.GetTableOfSelectedTickers(); } protected virtual void setTickers(DateTime currentDate, bool setGenomeCounter) { DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); if(setOfTickersToBeOptimized.Rows.Count > this.chosenTickers.Length*2) //the optimization process is possible only if the initial set of tickers is //as large as the number of tickers to be chosen { IGenomeManager genManEfficientCTOPortfolio = new GenomeManagerForEfficientCTOPortfolio(setOfTickersToBeOptimized, currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, this.numberOfTickersToBeChosen, this.targetReturn, this.portfolioType); GeneticOptimizer GO = new GeneticOptimizer(genManEfficientCTOPortfolio, this.populationSizeForGeneticOptimizer, this.generationNumberForGeneticOptimizer, this.seedForRandomGenerator); if(setGenomeCounter) this.genomeCounter = new GenomeCounter(GO); GO.Run(false); this.addGenomeToBestGenomes(GO.BestGenome,currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate); this.chosenTickers = ((GenomeMeaning)GO.BestGenome.Meaning).Tickers; this.chosenTickersPortfolioWeights = ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights; } //else it will be buyed again the previous optimized portfolio //that's it the actual chosenTickers member } protected void oneHourAfterMarketCloseEventHandler_updatePrices() { //min price for minimizing commission amount //according to IB Broker's commission scheme this.minPriceForMinimumCommission = this.account.CashAmount/(this.numberOfTickersToBeChosen*100); this.maxPriceForMinimumCommission = this.maxPriceForMinimumCommission; //just to avoid warning message } /// <summary> /// Handles a "One hour after market close" event. /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> public override void OneHourAfterMarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { this.seedForRandomGenerator++; this.orders.Clear(); //this.oneHourAfterMarketCloseEventHandler_updatePrices(); if(this.numDaysElapsedSinceLastOptimization == this.numDaysBetweenEachOptimization - 1) { this.setTickers(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime, false); //sets tickers to be chosen at next Market Open event this.numDaysElapsedSinceLastOptimization = 0; } else { this.numDaysElapsedSinceLastOptimization++; } } #endregion } } |
|
From: Marco M. <mi...@us...> - 2005-12-28 23:19:39
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/TestingOTCTypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25340/TestingOTCTypes Log Message: Directory /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/TestingOTCTypes added to the repository |
|
From: Glauco S. <gla...@us...> - 2005-12-27 15:43:23
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination/WalkForwardTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11770/b7_Scripts/WalkForwardTesting/LinearCombination/WalkForwardTest Modified Files: RunWalkForwardLinearCombination.cs Log Message: maxRunningHours has been added to the constructor Index: RunWalkForwardLinearCombination.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination/WalkForwardTest/RunWalkForwardLinearCombination.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RunWalkForwardLinearCombination.cs 11 Dec 2005 18:06:52 -0000 1.3 --- RunWalkForwardLinearCombination.cs 27 Dec 2005 15:43:14 -0000 1.4 *************** *** 56,59 **** --- 56,60 ---- private bool openToCloseDaily; + private DateTime deadlineForScript; private IHistoricalQuoteProvider historicalQuoteProvider; *************** *** 70,74 **** DateTime firstDate, DateTime lastDate, double targetReturn, PortfolioType portfolioType , ! bool openToCloseDaily ) { this.tickerGroupID = tickerGroupID; --- 71,76 ---- DateTime firstDate, DateTime lastDate, double targetReturn, PortfolioType portfolioType , ! bool openToCloseDaily , ! double maxRunningHours ) { this.tickerGroupID = tickerGroupID; *************** *** 87,90 **** --- 89,93 ---- this.portfolioType = portfolioType; this.openToCloseDaily = openToCloseDaily; + this.deadlineForScript = DateTime.Now.AddHours( maxRunningHours ); } *************** *** 92,97 **** EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! if ( this.account.EndOfDayTimer.GetCurrentTime().DateTime >= ! this.lastDate ) this.account.EndOfDayTimer.Stop(); } --- 95,101 ---- EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! if ( ( this.account.EndOfDayTimer.GetCurrentTime().DateTime >= ! this.lastDate ) || ! ( DateTime.Now > this.deadlineForScript ) ) this.account.EndOfDayTimer.Stop(); } *************** *** 125,129 **** new IndexBasedEndOfDayTimer( new EndOfDayDateTime( this.firstDate , ! EndOfDaySpecificTime.MarketOpen ) , "DYN" ); run_setHistoricalQuoteProvider(); this.account = new Account( "LinearCombination" , historicalEndOfDayTimer , --- 129,133 ---- new IndexBasedEndOfDayTimer( new EndOfDayDateTime( this.firstDate , ! EndOfDaySpecificTime.MarketOpen ) , "MSFT" ); run_setHistoricalQuoteProvider(); this.account = new Account( "LinearCombination" , historicalEndOfDayTimer , |
|
From: Marco M. <mi...@us...> - 2005-12-20 19:51:00
|
Update of /cvsroot/quantproject/QuantProject/b4_Business In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19780/b4_Business Modified Files: Business.prjx Log Message: Updated #develop project files Index: Business.prjx =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/Business.prjx,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Business.prjx 21 Oct 2005 18:18:58 -0000 1.7 --- Business.prjx 20 Dec 2005 19:50:52 -0000 1.8 *************** *** 95,98 **** --- 95,102 ---- <File name=".\a1_Financial\a2_Accounting\EquityLine.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> <File name=".\a1_Financial\a2_Accounting\PositionType.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\a1_Financial\a2_Accounting\Slippage\ISlippageManager.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\a1_Financial\a2_Accounting\Slippage\ZeroSlippageManager.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\a1_Financial\a2_Accounting\Slippage\FixedPercentageSlippageManager.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\a1_Financial\a2_Accounting\RebuildableAccount.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> </Contents> <References> |
|
From: Marco M. <mi...@us...> - 2005-12-20 19:51:00
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19780/b7_Scripts Modified Files: Scripts.prjx Log Message: Updated #develop project files Index: Scripts.prjx =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/Scripts.prjx,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Scripts.prjx 8 Nov 2005 18:43:18 -0000 1.15 --- Scripts.prjx 20 Dec 2005 19:50:52 -0000 1.16 *************** *** 28,32 **** <File name=".\TickerSelectionTesting\RunEfficientPortfolio.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> <File name=".\TickerSelectionTesting\PortfolioType.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> - <File name=".\WalkForwardTesting\WalkForwardOneRank\IWalkForwardProgressNotifier.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> <File name=".\TickerSelectionTesting\RunTestOptimizedCTOPortfolio.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> <File name=".\TickerSelectionTesting\EndOfDayTimerHandlerCTOTest.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> --- 28,31 ---- *************** *** 38,42 **** <File name=".\WalkForwardTesting\LinearCombination\GenomeRepresentation.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> <File name=".\TickerSelectionTesting\CandidateProperties.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> - <File name=".\WalkForwardTesting\LinearCombination\VisualObjectArchiver.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> <File name=".\WalkForwardTesting\LinearCombination\LinearCombinationTest.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> <File name=".\WalkForwardTesting\LinearCombination\MainForm.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> --- 37,40 ---- *************** *** 72,75 **** --- 70,85 ---- <File name=".\TickerSelectionTesting\GenomeMeaning.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> <File name=".\TickerSelectionTesting\GenomeManagerForWeightedEfficientPortfolio.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\WalkForwardTesting\WalkForwardMultiOneRank" subtype="Directory" buildaction="Compile" dependson="" data="" /> + <File name=".\WalkForwardTesting\WalkForwardMultiOneRank\WFMultiOneRankGenomeManager.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\WalkForwardTesting\WalkForwardMultiOneRank\RunWalkForwardMultiOneRank.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\WalkForwardTesting\WalkForwardMultiOneRank\WFMultiOneRankChosenTickers.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\WalkForwardTesting\WalkForwardMultiOneRank\WFMultiOneRankEligibleTickers.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\WalkForwardTesting\WalkForwardMultiOneRank\ReportDebugger\WFMultiOneRankDebugInSample.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\WalkForwardTesting\WalkForwardMultiOneRank\WFMultiOneRankEndOfDayTimerHandler.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\WalkForwardTesting\WalkForwardMultiOneRank\ReportDebugger\WFMultiOneRankDebugEndOfDayTimerHandler.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\WalkForwardTesting\WalkForwardMultiOneRank\ReportDebugger\WFMultiOneRankReportDebugger.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\WalkForwardTesting\IWalkForwardProgressNotifier.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\WalkForwardTesting\WalkForwardMultiOneRank\ReportDebugger\WFMultiOneRankDebugInSampleForm.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\WalkForwardTesting\WalkForwardMultiOneRank\ReportDebugger\WFMultiOneRankRunInSampleDebug.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> </Contents> <References> |
|
From: Marco M. <mi...@us...> - 2005-12-20 19:50:59
|
Update of /cvsroot/quantproject/QuantProject/b5_Presentation In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19780/b5_Presentation Modified Files: Presentation.prjx Log Message: Updated #develop project files Index: Presentation.prjx =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b5_Presentation/Presentation.prjx,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Presentation.prjx 24 Jun 2005 22:54:51 -0000 1.4 --- Presentation.prjx 20 Dec 2005 19:50:52 -0000 1.5 *************** *** 16,19 **** --- 16,20 ---- <File name=".\Reporting\WindowsForm\AccountViewer.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> <File name=".\Reporting\WindowsForm\SummaryItem.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> + <File name=".\VisualObjectArchiver.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> </Contents> <References> |
|
From: Marco M. <mi...@us...> - 2005-12-20 19:50:33
|
Update of /cvsroot/quantproject/QuantProject/b4_Business In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19676/b4_Business Modified Files: b4_Business.csproj Log Message: Added classes for slippage management Index: b4_Business.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/b4_Business.csproj,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** b4_Business.csproj 11 Dec 2005 18:22:48 -0000 1.29 --- b4_Business.csproj 20 Dec 2005 19:50:21 -0000 1.30 *************** *** 503,506 **** --- 503,521 ---- /> <File + RelPath = "a1_Financial\a2_Accounting\Slippage\FixedPercentageSlippageManager.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "a1_Financial\a2_Accounting\Slippage\ISlippageManager.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "a1_Financial\a2_Accounting\Slippage\ZeroSlippageManager.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "a1_Financial\a2_Accounting\Transactions\EndOfDayTransaction.cs" SubType = "Code" |
|
From: Marco M. <mi...@us...> - 2005-12-20 19:45:14
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/Selectors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18478/b3_Data/Selectors Modified Files: SelectorByAbsolutePerformance.cs Log Message: Now it is possible to select tickers with a performance within a given range. Index: SelectorByAbsolutePerformance.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/Selectors/SelectorByAbsolutePerformance.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SelectorByAbsolutePerformance.cs 27 Feb 2005 19:56:07 -0000 1.1 --- SelectorByAbsolutePerformance.cs 20 Dec 2005 19:45:02 -0000 1.2 *************** *** 35,40 **** public class SelectorByAbsolutePerformance : TickerSelector, ITickerSelector { ! ! public SelectorByAbsolutePerformance(DataTable setOfTickersToBeSelected, bool orderInASCmode, --- 35,41 ---- public class SelectorByAbsolutePerformance : TickerSelector, ITickerSelector { ! private float minAbsoluteSimpleReturn = -1; ! private float maxAbsoluteSimpleReturn = -1; ! public SelectorByAbsolutePerformance(DataTable setOfTickersToBeSelected, bool orderInASCmode, *************** *** 63,67 **** } ! public DataTable GetTableOfSelectedTickers() --- 64,99 ---- } ! public SelectorByAbsolutePerformance(DataTable setOfTickersToBeSelected, ! bool orderInASCmode, ! DateTime firstQuoteDate, ! DateTime lastQuoteDate, ! long maxNumOfReturnedTickers, ! float minAbsoluteSimpleReturn, ! float maxAbsoluteSimpleReturn): ! base(setOfTickersToBeSelected, ! orderInASCmode, ! firstQuoteDate, ! lastQuoteDate, ! maxNumOfReturnedTickers) ! { ! this.minAbsoluteSimpleReturn = minAbsoluteSimpleReturn; ! this.maxAbsoluteSimpleReturn = maxAbsoluteSimpleReturn; ! } ! public SelectorByAbsolutePerformance(string groupID, ! bool orderInASCmode, ! DateTime firstQuoteDate, ! DateTime lastQuoteDate, ! long maxNumOfReturnedTickers, ! float minAbsoluteSimpleReturn, ! float maxAbsoluteSimpleReturn): ! base(groupID, ! orderInASCmode, ! firstQuoteDate, ! lastQuoteDate, ! maxNumOfReturnedTickers) ! { ! this.minAbsoluteSimpleReturn = minAbsoluteSimpleReturn; ! this.maxAbsoluteSimpleReturn = maxAbsoluteSimpleReturn; ! } public DataTable GetTableOfSelectedTickers() *************** *** 72,76 **** this.firstQuoteDate, this.lastQuoteDate, ! this.maxNumOfReturnedTickers); else return TickerDataTable.GetTickersByPerformance(this.isOrderedInASCMode, --- 104,110 ---- this.firstQuoteDate, this.lastQuoteDate, ! this.maxNumOfReturnedTickers, ! this.minAbsoluteSimpleReturn, ! this.maxAbsoluteSimpleReturn); else return TickerDataTable.GetTickersByPerformance(this.isOrderedInASCMode, *************** *** 78,82 **** this.firstQuoteDate, this.lastQuoteDate, ! this.maxNumOfReturnedTickers); } --- 112,118 ---- this.firstQuoteDate, this.lastQuoteDate, ! this.maxNumOfReturnedTickers, ! this.minAbsoluteSimpleReturn, ! this.maxAbsoluteSimpleReturn); } |
|
From: Marco M. <mi...@us...> - 2005-12-20 19:38:09
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a3_Ordering In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17455/b4_Business/a1_Financial/a3_Ordering Modified Files: HistoricalEndOfDayOrderExecutor.cs Log Message: Added slippage management code (through ISlippageManager interface) Index: HistoricalEndOfDayOrderExecutor.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a3_Ordering/HistoricalEndOfDayOrderExecutor.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** HistoricalEndOfDayOrderExecutor.cs 4 Feb 2005 00:10:25 -0000 1.5 --- HistoricalEndOfDayOrderExecutor.cs 20 Dec 2005 19:37:57 -0000 1.6 *************** *** 29,32 **** --- 29,33 ---- using QuantProject.Business.Financial.Accounting.Transactions; using QuantProject.Business.Timing; + using QuantProject.Business.Financial.Accounting.Slippage; *************** *** 41,44 **** --- 42,46 ---- private IEndOfDayTimer timer; private IHistoricalQuoteProvider historicalQuoteProvider; + private ISlippageManager slippageManager; public HistoricalEndOfDayOrderExecutor( IEndOfDayTimer timer , *************** *** 47,51 **** --- 49,61 ---- this.timer = timer; this.historicalQuoteProvider = historicalQuoteProvider; + this.slippageManager = new ZeroSlippageManager(); } + public HistoricalEndOfDayOrderExecutor( IEndOfDayTimer timer , + IHistoricalQuoteProvider historicalQuoteProvider, ISlippageManager slippageManager ) + { + this.timer = timer; + this.historicalQuoteProvider = historicalQuoteProvider; + this.slippageManager = slippageManager; + } [field:NonSerialized] public event OrderFilledEventHandler OrderFilled; *************** *** 54,62 **** public void Execute( Order order ) { ! double instrumentPrice = this.historicalQuoteProvider.GetMarketValue( order.Instrument.Key , ! this.timer.GetCurrentTime() ); ! EndOfDayTransaction endOfDayTransaction = new EndOfDayTransaction( TimedTransaction.GetTransactionType( order.Type ) , order.Instrument , ! order.Quantity , instrumentPrice , new EndOfDayDateTime( this.timer.GetCurrentTime().DateTime , this.timer.GetCurrentTime().EndOfDaySpecificTime ) ); --- 64,75 ---- public void Execute( Order order ) { ! double instrumentMarketPrice = ! this.historicalQuoteProvider.GetMarketValue(order.Instrument.Key , ! this.timer.GetCurrentTime()); ! double instrumentPriceWithSlippage = instrumentMarketPrice + ! this.slippageManager.GetSlippage(order); ! EndOfDayTransaction endOfDayTransaction = new EndOfDayTransaction( TimedTransaction.GetTransactionType( order.Type ) , order.Instrument , ! order.Quantity , instrumentPriceWithSlippage , new EndOfDayDateTime( this.timer.GetCurrentTime().DateTime , this.timer.GetCurrentTime().EndOfDaySpecificTime ) ); |
|
From: Marco M. <mi...@us...> - 2005-12-20 19:36:06
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17179/b4_Business/a05_Timing Modified Files: IndexBasedEndOfDayTimer.cs Log Message: Added GetPreviousDateTime method Index: IndexBasedEndOfDayTimer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing/IndexBasedEndOfDayTimer.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** IndexBasedEndOfDayTimer.cs 6 Mar 2005 21:37:17 -0000 1.5 --- IndexBasedEndOfDayTimer.cs 20 Dec 2005 19:35:53 -0000 1.6 *************** *** 84,88 **** this.currentTime.EndOfDaySpecificTime = nextSpecificTime; } ! } --- 84,94 ---- this.currentTime.EndOfDaySpecificTime = nextSpecificTime; } ! /// <summary> ! /// Gets the previous index based date time ! /// </summary> ! public DateTime GetPreviousDateTime() ! { ! return this.indexQuotes.GetPrecedingDate(this.currentTime.DateTime,1); ! } } |
|
From: Marco M. <mi...@us...> - 2005-12-20 19:35:07
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/Selectors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16980/b3_Data/Selectors Modified Files: SelectionType.cs Log Message: Added new selection types Index: SelectionType.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/Selectors/SelectionType.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** SelectionType.cs 17 May 2005 23:06:01 -0000 1.11 --- SelectionType.cs 20 Dec 2005 19:34:55 -0000 1.12 *************** *** 42,46 **** AverageRawOpenPrice, WinningOpenToClose, ! OpenCloseCorrelationToBenchmark } } --- 42,47 ---- AverageRawOpenPrice, WinningOpenToClose, ! OpenCloseCorrelationToBenchmark, ! CloseToCloseCorrelationToBenchmark } } |
|
From: Marco M. <mi...@us...> - 2005-12-20 19:33:40
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataTables In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16728/b3_Data/DataTables Modified Files: Quotes.cs Log Message: Updated GetTickersByPrice method Index: Quotes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataTables/Quotes.cs,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Quotes.cs 17 Nov 2005 21:34:40 -0000 1.19 --- Quotes.cs 20 Dec 2005 19:33:12 -0000 1.20 *************** *** 328,341 **** double maxStdDeviation) { ! int numRows = setOfTickers.Rows.Count; ! for(int i = 0; i<numRows; i++) { ! double averagePrice = (double)setOfTickers.Rows[i]["AverageRawOpenPrice"]; ! double stdDeviation = (double)setOfTickers.Rows[i]["RawOpenPriceStdDev"]; ! if (averagePrice < minPrice || averagePrice > maxPrice || ! stdDeviation < minStdDeviation || stdDeviation > maxStdDeviation) ! //values of rows DON'T respect given criteria ! setOfTickers.Rows[i].Delete(); ! } } --- 328,349 ---- double maxStdDeviation) { ! int currentNumRows = setOfTickers.Rows.Count; ! for(int i = 0;i<currentNumRows;i++) { ! if(setOfTickers.Rows[i].RowState != DataRowState.Deleted) ! { ! double averagePrice = (double)setOfTickers.Rows[i]["AverageRawOpenPrice"]; ! double stdDeviation = (double)setOfTickers.Rows[i]["RawOpenPriceStdDev"]; ! if (averagePrice < minPrice || averagePrice > maxPrice || ! stdDeviation < minStdDeviation || stdDeviation > maxStdDeviation) ! //values of rows DON'T respect given criteria ! { ! setOfTickers.Rows[i].Delete(); ! currentNumRows = setOfTickers.Rows.Count; ! i--;//deletion causes the new ID row ! //of the next row to be the ID row of the deleted Row ! //so, only in this way, all the rows are checked ! } ! } } } *************** *** 447,464 **** return tableToReturn; } ! public static float[] GetArrayOfCloseToCloseRatios(string ticker, DateTime firstQuoteDate, DateTime lastQuoteDate, ! int numDaysBetweenEachClose) { float[] returnValue = null; Quotes tickerQuotes = new Quotes(ticker, firstQuoteDate, lastQuoteDate); float[] allAdjValues = ExtendedDataTable.GetArrayOfFloatFromColumn(tickerQuotes, "quAdjustedClose"); ! returnValue = new float[allAdjValues.Length/(numDaysBetweenEachClose + 1)]; int i = 0; //index for ratesOfReturns array int lastIdxAccessed = 0; for(int idx = 0; ! (idx + numDaysBetweenEachClose) < allAdjValues.Length; idx += numDaysBetweenEachClose ) { --- 455,487 ---- return tableToReturn; } ! /// <summary> ! /// Gets an array containing close to close ratios ! /// </summary> ! /// <param name="ticker"></param> ! /// <param name="firstQuoteDate"></param> ! /// <param name="lastQuoteDate"></param> ! /// <param name="numDaysBetweenEachClose">Num of days the close to close ratio refers to</param> ! /// <param name="numOfInitialMarketDaysToJump">Num of initial market days that has not to be ! /// considered in the calculation</param> ! /// <returns></returns> public static float[] GetArrayOfCloseToCloseRatios(string ticker, DateTime firstQuoteDate, DateTime lastQuoteDate, ! int numDaysBetweenEachClose, ! int numOfInitialMarketDaysToJump) { float[] returnValue = null; Quotes tickerQuotes = new Quotes(ticker, firstQuoteDate, lastQuoteDate); float[] allAdjValues = ExtendedDataTable.GetArrayOfFloatFromColumn(tickerQuotes, "quAdjustedClose"); ! float[] adjValuesMinusInitialMarketDays = new float[allAdjValues.Length - numOfInitialMarketDaysToJump]; ! for(int k = 0;k<allAdjValues.Length - numOfInitialMarketDaysToJump;k++) ! adjValuesMinusInitialMarketDays[k] = ! allAdjValues[k + numOfInitialMarketDaysToJump]; ! ! returnValue = new float[adjValuesMinusInitialMarketDays.Length/(numDaysBetweenEachClose + 1)]; int i = 0; //index for ratesOfReturns array int lastIdxAccessed = 0; for(int idx = 0; ! (idx + numDaysBetweenEachClose) < adjValuesMinusInitialMarketDays.Length; idx += numDaysBetweenEachClose ) { *************** *** 466,471 **** //there is a discontinuity, as wanted { ! returnValue[i] = (allAdjValues[idx+numDaysBetweenEachClose]/ ! allAdjValues[idx] - 1); lastIdxAccessed = idx; i++; --- 489,494 ---- //there is a discontinuity, as wanted { ! returnValue[i] = (adjValuesMinusInitialMarketDays[idx+numDaysBetweenEachClose]/ ! adjValuesMinusInitialMarketDays[idx] - 1); lastIdxAccessed = idx; i++; *************** *** 475,478 **** --- 498,509 ---- } + public static float[] GetArrayOfCloseToCloseRatios(string ticker, + DateTime firstQuoteDate, + DateTime lastQuoteDate, + int numDaysBetweenEachClose) + { + return GetArrayOfCloseToCloseRatios(ticker, firstQuoteDate, lastQuoteDate, numDaysBetweenEachClose, + 0); + } /// <summary> /// returns tickers of a given set of tickers ordered by close to close |
|
From: Marco M. <mi...@us...> - 2005-12-20 19:31:12
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataTables In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16324/b3_Data/DataTables Modified Files: TickerDataTable.cs Log Message: Updated GetTickersByPerformance method Index: TickerDataTable.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataTables/TickerDataTable.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TickerDataTable.cs 6 Jan 2005 18:56:55 -0000 1.5 --- TickerDataTable.cs 20 Dec 2005 19:31:02 -0000 1.6 *************** *** 26,29 **** --- 26,30 ---- using QuantProject.DataAccess.Tables; + namespace QuantProject.Data.DataTables { *************** *** 59,72 **** } public static DataTable GetTickersByPerformance(bool orderByASC, string groupID, ! DateTime firstQuoteDate, ! DateTime lastQuoteDate, ! long maxNumOfReturnedTickers) { DataTable groupOfTicker = QuantProject.DataAccess.Tables.Tickers_tickerGroups.GetTickers(groupID); ! //also possible, but slower: ! //return TickerDataTable.GetBestPerformingTickers(orderByASC, groupOfTicker, firstQuoteDate, ! // lastQuoteDate, maxNumOfReturnedTickers); ! TickerDataTable.addColumnsForPerformanceAnalysis(groupOfTicker); DateTime firstAvailableQuoteDate, lastAvailableQuoteDate; --- 60,106 ---- } + #region GetTickersByPerformance + + private static void addColumnsForPerformanceAnalysis(DataTable tableToAnalyze) + { + if(!tableToAnalyze.Columns.Contains("SimpleReturn")) + tableToAnalyze.Columns.Add("SimpleReturn", System.Type.GetType("System.Double")); + if(!tableToAnalyze.Columns.Contains("PeriodForSimpleReturn")) + tableToAnalyze.Columns.Add("PeriodForSimpleReturn", System.Type.GetType("System.String")); + } + + private static string getTickersByPerformance_getFilterExpression(float minAbsoluteSimpleReturn, + float maxAbsoluteSimpleReturn) + { + string returnValue = ""; + if(minAbsoluteSimpleReturn > 0 && + maxAbsoluteSimpleReturn > 0) + //both limits have to be greater than zero + { + returnValue = "(" + minAbsoluteSimpleReturn.ToString("#.##") + + "<=SimpleReturn AND " + + maxAbsoluteSimpleReturn.ToString("#.##") + + ">=SimpleReturn)" + + " OR " + + "(" + "-" + maxAbsoluteSimpleReturn.ToString("#.##") + + "<SimpleReturn AND " + + "-" + minAbsoluteSimpleReturn.ToString("#.##") + + ">SimpleReturn)"; + } + return returnValue; + } + public static DataTable GetTickersByPerformance(bool orderByASC, string groupID, ! DateTime firstQuoteDate, ! DateTime lastQuoteDate, ! long maxNumOfReturnedTickers, ! float minAbsoluteSimpleReturn, ! float maxAbsoluteSimpleReturn) { DataTable groupOfTicker = QuantProject.DataAccess.Tables.Tickers_tickerGroups.GetTickers(groupID); ! ! //return TickerDataTable.GetTickersByPerformance(orderByASC, groupOfTicker, firstQuoteDate, ! // lastQuoteDate, maxNumOfReturnedTickers, minAbsoluteSimpleReturn, maxAbsoluteSimpleReturn); ! TickerDataTable.addColumnsForPerformanceAnalysis(groupOfTicker); DateTime firstAvailableQuoteDate, lastAvailableQuoteDate; *************** *** 87,101 **** } } ! ExtendedDataTable.Sort(groupOfTicker, "SimpleReturn", orderByASC); ExtendedDataTable.DeleteRows(groupOfTicker, maxNumOfReturnedTickers); return groupOfTicker; } public static DataTable GetTickersByPerformance(bool orderByASC, DataTable setOfTickers, DateTime firstQuoteDate, DateTime lastQuoteDate, ! long maxNumOfReturnedTickers) { TickerDataTable.addColumnsForPerformanceAnalysis(setOfTickers); DateTime firstAvailableQuoteDate, lastAvailableQuoteDate; --- 121,154 ---- } } ! string filterExpression = ! getTickersByPerformance_getFilterExpression(minAbsoluteSimpleReturn, ! maxAbsoluteSimpleReturn); ! ExtendedDataTable.CopyAndSort(groupOfTicker, filterExpression, ! "SimpleReturn", orderByASC); ExtendedDataTable.DeleteRows(groupOfTicker, maxNumOfReturnedTickers); return groupOfTicker; + } + + public static DataTable GetTickersByPerformance(bool orderByASC, string groupID, + DateTime firstQuoteDate, + DateTime lastQuoteDate, + long maxNumOfReturnedTickers) + { + return TickerDataTable.GetTickersByPerformance(orderByASC, groupID, firstQuoteDate, + lastQuoteDate, maxNumOfReturnedTickers, + -1, -1); + } + public static DataTable GetTickersByPerformance(bool orderByASC, DataTable setOfTickers, DateTime firstQuoteDate, DateTime lastQuoteDate, ! long maxNumOfReturnedTickers, ! float minAbsoluteSimpleReturn, ! float maxAbsoluteSimpleReturn) { + DataTable returnValue; TickerDataTable.addColumnsForPerformanceAnalysis(setOfTickers); DateTime firstAvailableQuoteDate, lastAvailableQuoteDate; *************** *** 115,130 **** } } ! ExtendedDataTable.Sort(setOfTickers, "SimpleReturn", orderByASC); ! ExtendedDataTable.DeleteRows(setOfTickers, maxNumOfReturnedTickers); ! return setOfTickers; } ! ! private static void addColumnsForPerformanceAnalysis(DataTable tableToAnalyze) { ! if(!tableToAnalyze.Columns.Contains("SimpleReturn")) ! tableToAnalyze.Columns.Add("SimpleReturn", System.Type.GetType("System.Double")); ! if(!tableToAnalyze.Columns.Contains("PeriodForSimpleReturn")) ! tableToAnalyze.Columns.Add("PeriodForSimpleReturn", System.Type.GetType("System.String")); } private static void addColumnNumberOfQuotes(DataTable tableToAnalyze) --- 168,192 ---- } } ! string filterExpression = ! getTickersByPerformance_getFilterExpression(minAbsoluteSimpleReturn, ! maxAbsoluteSimpleReturn); ! returnValue = ExtendedDataTable.CopyAndSort(setOfTickers, ! filterExpression, ! "SimpleReturn", ! orderByASC); ! ExtendedDataTable.DeleteRows(returnValue, maxNumOfReturnedTickers); ! return returnValue; } ! ! public static DataTable GetTickersByPerformance(bool orderByASC, DataTable setOfTickers, ! DateTime firstQuoteDate, ! DateTime lastQuoteDate, ! long maxNumOfReturnedTickers) { ! return GetTickersByPerformance(orderByASC, setOfTickers, firstQuoteDate,lastQuoteDate, ! maxNumOfReturnedTickers, -1, -1); } + #endregion + private static void addColumnNumberOfQuotes(DataTable tableToAnalyze) |
|
From: Marco M. <mi...@us...> - 2005-12-20 19:30:08
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/Selectors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15971/b3_Data/Selectors Modified Files: SelectorByCloseToCloseCorrelationToBenchmark.cs Log Message: Added documentation comments Index: SelectorByCloseToCloseCorrelationToBenchmark.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/Selectors/SelectorByCloseToCloseCorrelationToBenchmark.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SelectorByCloseToCloseCorrelationToBenchmark.cs 17 Nov 2005 21:34:40 -0000 1.1 --- SelectorByCloseToCloseCorrelationToBenchmark.cs 20 Dec 2005 19:29:57 -0000 1.2 *************** *** 33,36 **** --- 33,40 ---- /// Class for selection on tickers by close to close absolute correlation to /// a given benchmark + /// NOTE that + /// close values are grouped in pairs and the first close value in each group is + /// not the last close in the previous group. There is, in other words, a discontinuity + /// between each group, with length equal to the group's length /// </summary> public class SelectorByCloseToCloseCorrelationToBenchmark : TickerSelector, ITickerSelector *************** *** 38,42 **** private string benchmark; private int numDaysBetweenEachClose; ! public SelectorByCloseToCloseCorrelationToBenchmark(DataTable setOfTickersToBeSelected, string benchmark, --- 42,58 ---- private string benchmark; private int numDaysBetweenEachClose; ! /// <summary> ! /// Creates a new instance of the selector ! /// </summary> ! /// <param name="setOfTickersToBeSelected">The data table containing in the first column the tickers that have to be ordered</param> ! /// <param name="benchmark">Benchmark code</param> ! /// <param name="orderInASCmode">Ordering mode</param> ! /// <param name="firstQuoteDate">The first date for the interval</param> ! /// <param name="lastQuoteDate">The last date for the interval</param> ! /// <param name="maxNumOfReturnedTickers">Max number of tickers to be returned</param> ! /// <param name="numDaysBetweenEachClose">Number of days between closes to be studied. NOTE that ! /// close values are grouped in pairs and the first close value in each group is ! /// not the last close in the previous group. There is, in other words, a discontinuity ! /// between each group, with length equal to the group's length </param> public SelectorByCloseToCloseCorrelationToBenchmark(DataTable setOfTickersToBeSelected, string benchmark, *************** *** 55,58 **** --- 71,88 ---- this.numDaysBetweenEachClose = numDaysBetweenEachClose; } + + /// <summary> + /// Creates a new instance of the selector + /// </summary> + /// <param name="groupID">The group ID containing the tickers that have to be ordered</param> + /// <param name="benchmark">Benchmark code</param> + /// <param name="orderInASCmode">Ordering mode</param> + /// <param name="firstQuoteDate">The first date for the interval</param> + /// <param name="lastQuoteDate">The last date for the interval</param> + /// <param name="maxNumOfReturnedTickers">Max number of tickers to be returned</param> + /// <param name="numDaysBetweenEachClose">Number of days between closes to be studied. NOTE that + /// close values are grouped in pairs and the first close value in each group is + /// not the last close in the previous group. There is, in other words, a discontinuity + /// between each group, with length equal to the group's length </param> public SelectorByCloseToCloseCorrelationToBenchmark(string groupID, string benchmark, |
|
From: Marco M. <mi...@us...> - 2005-12-20 19:27:25
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/Slippage In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15524 Added Files: ZeroSlippageManager.cs ISlippageManager.cs FixedPercentageSlippageManager.cs Log Message: Added classes for slippage management --- NEW FILE: FixedPercentageSlippageManager.cs --- /* QuantProject - Quantitative Finance Library FixedPercentageSlippageManager.cs Copyright (C) 2003 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.Business.Financial.Ordering; using QuantProject.Business.DataProviders; using QuantProject.Business.Timing; namespace QuantProject.Business.Financial.Accounting.Slippage { /// <summary> /// Slippage Manager for a slippage computed as a fixed percentage of price. /// </summary> [Serializable] public class FixedPercentageSlippageManager : ISlippageManager { private double percentage; private IHistoricalQuoteProvider quoteProvider; private IEndOfDayTimer endOfDayTimer; public FixedPercentageSlippageManager(IHistoricalQuoteProvider quoteProvider, IEndOfDayTimer endOfDayTimer, double percentage) { this.quoteProvider = quoteProvider; this.endOfDayTimer = endOfDayTimer; this.percentage = percentage; } public double GetSlippage(Order order) { double returnValue = 0.0; double marketPrice; if(order.Type == OrderType.LimitBuy || order.Type == OrderType.LimitCover || order.Type == OrderType.MarketBuy || order.Type == OrderType.MarketCover) { //it should be GetCurrentBid marketPrice = this.quoteProvider.GetMarketValue(order.Instrument.Key, endOfDayTimer.GetCurrentTime()); returnValue = percentage * marketPrice / 100.00; } else//sell type or sellShort type, limit or not { //it should be GetCurrentAsk marketPrice = this.quoteProvider.GetMarketValue(order.Instrument.Key, endOfDayTimer.GetCurrentTime()); returnValue = -percentage * marketPrice / 100.00; } return returnValue; } } } --- NEW FILE: ZeroSlippageManager.cs --- /* QuantProject - Quantitative Finance Library ZeroSlippageManager.cs Copyright (C) 2003 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; namespace QuantProject.Business.Financial.Accounting.Slippage { /// <summary> /// Slippage Manager for Zero value slippage. /// This is the slippage manager used by an Account /// if no ISlippageManager is specified. /// </summary> [Serializable] public class ZeroSlippageManager : ISlippageManager { public ZeroSlippageManager() { } public double GetSlippage( Ordering.Order order ) { return 0.0; } } } --- NEW FILE: ISlippageManager.cs --- /* QuantProject - Quantitative Finance Library ISlippageManager.cs Copyright (C) 2003 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; namespace QuantProject.Business.Financial.Accounting.Slippage { /// <summary> /// Interface to be implemented by slippage managers /// (for calculation of slippage) /// </summary> public interface ISlippageManager { double GetSlippage(Ordering.Order order); } } |
|
From: Marco M. <mi...@us...> - 2005-12-20 19:23:17
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/Slippage In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14586/Slippage Log Message: Directory /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/Slippage added to the repository |
|
From: Glauco S. <gla...@us...> - 2005-12-11 18:23:08
|
Update of /cvsroot/quantproject/QuantProject/b4_Business In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13723/b4_Business Modified Files: b4_Business.csproj Log Message: a1_Financial\a2_Accounting\RebuildableAccount.cs has been added Index: b4_Business.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/b4_Business.csproj,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** b4_Business.csproj 15 Oct 2005 18:00:19 -0000 1.28 --- b4_Business.csproj 11 Dec 2005 18:22:48 -0000 1.29 *************** *** 293,296 **** --- 293,301 ---- /> <File + RelPath = "a1_Financial\a2_Accounting\RebuildableAccount.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "a1_Financial\a2_Accounting\TimedTransaction.cs" SubType = "Code" |
|
From: Glauco S. <gla...@us...> - 2005-12-11 18:22:42
|
Update of /cvsroot/quantproject/QuantProject/b5_Presentation In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13602/b5_Presentation Modified Files: b5_Presentation.csproj Log Message: VisualObjectArchiver.cs has been added Index: b5_Presentation.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b5_Presentation/b5_Presentation.csproj,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** b5_Presentation.csproj 15 Oct 2005 18:01:31 -0000 1.25 --- b5_Presentation.csproj 11 Dec 2005 18:22:24 -0000 1.26 *************** *** 158,161 **** --- 158,166 ---- /> <File + RelPath = "VisualObjectArchiver.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Charting\CharPlot.cs" SubType = "Code" |