[Quantproject-developers] QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagDebugger/W
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2006-07-30 13:40:39
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagDebugger/WFLagDebugPositions In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv8814/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagDebugger/WFLagDebugPositions Modified Files: WFLagDebugPositionsEndOfDayTimerHandler.cs Log Message: WeightedPositions are used instead of SignedTickers Index: WFLagDebugPositionsEndOfDayTimerHandler.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagDebugger/WFLagDebugPositions/WFLagDebugPositionsEndOfDayTimerHandler.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WFLagDebugPositionsEndOfDayTimerHandler.cs 8 Apr 2006 18:16:08 -0000 1.1 --- WFLagDebugPositionsEndOfDayTimerHandler.cs 30 Jul 2006 13:40:35 -0000 1.2 *************** *** 52,59 **** double todayTotalGain = 0; DateTime today = this.account.EndOfDayTimer.GetCurrentTime().DateTime; ! foreach ( string signedTicker in ! this.wFLagChosenPositions.DrivingPositions.Keys ) todayTotalGain += ! SignedTicker.GetCloseToCloseDailyReturn( signedTicker , today ); // todayTotalGain += totalGainForSignedTicker( signedTicker ); return todayTotalGain; --- 52,59 ---- double todayTotalGain = 0; DateTime today = this.account.EndOfDayTimer.GetCurrentTime().DateTime; ! foreach ( WeightedPosition weightedPosition in ! this.wFLagChosenPositions.DrivingWeightedPositions.Values ) todayTotalGain += ! weightedPosition.GetCloseToCloseDailyReturn( today ); // todayTotalGain += totalGainForSignedTicker( signedTicker ); return todayTotalGain; *************** *** 64,68 **** return todayTotalGain > 0; } ! private string getFirstAccountPosition() { IEnumerator accountPositions = --- 64,68 ---- return todayTotalGain > 0; } ! private Position getFirstAccountPosition() { IEnumerator accountPositions = *************** *** 70,82 **** accountPositions.MoveNext(); Position firstPosition = (Position)accountPositions.Current; ! string firstAccountPosition = SignedTicker.GetSignedTicker( firstPosition ); ! return firstAccountPosition; } private bool isCurrentlyReversed() { ! string firstAccountPosition = this.getFirstAccountPosition(); bool isReversed = ! this.wFLagChosenPositions.PortfolioPositions.ContainsKey( ! SignedTicker.GetOppositeSignedTicker( firstAccountPosition ) ); return isReversed; } --- 70,87 ---- accountPositions.MoveNext(); Position firstPosition = (Position)accountPositions.Current; ! return firstPosition; } private bool isCurrentlyReversed() { ! Position firstAccountPosition = this.getFirstAccountPosition(); ! WeightedPosition weightedPosition = ! this.wFLagChosenPositions.PortfolioWeightedPositions.GetWeightedPosition( ! firstAccountPosition.Instrument.Key ); bool isReversed = ! ( ( weightedPosition.IsLong && firstAccountPosition.IsShort ) || ! ( weightedPosition.IsShort && firstAccountPosition.IsLong ) ); ! // bool isReversed = ! // this.wFLagChosenPositions.PortfolioWeightedPositions.ContainsKey( ! // SignedTicker.GetOppositeSignedTicker( firstAccountPosition ) ); return isReversed; } *************** *** 103,153 **** return returnValue; } ! private long getQuantity( string ticker ) { double accountValue = this.account.GetMarketValue(); double currentTickerAsk = ! this.account.DataStreamer.GetCurrentAsk( ticker ); double maxPositionValueForThisTicker = ! accountValue / this.wFLagChosenPositions.PortfolioPositions.Count; long quantity = Convert.ToInt64( Math.Floor( maxPositionValueForThisTicker / currentTickerAsk ) ); return quantity; } ! private void openPosition( string ticker , OrderType orderType ) { ! long quantity = this.getQuantity( ticker ); ! Order order = new Order( orderType , new Instrument( ticker ) , ! quantity ); this.account.AddOrder( order ); } private void fiveMinutesBeforeMarketCloseEventHandler_openThisPosition( ! string signedTicker ) { ! this.openPosition( SignedTicker.GetTicker( signedTicker ) , ! SignedTicker.GetMarketOrderType( signedTicker ) ); } private void fiveMinutesBeforeMarketCloseEventHandler_openOppositePosition( ! string signedTicker ) { this.fiveMinutesBeforeMarketCloseEventHandler_openThisPosition( ! SignedTicker.GetOppositeSignedTicker( signedTicker ) ); } private void fiveMinutesBeforeMarketCloseEventHandler_openPosition( ! string signedTicker ) { if ( this.isDrivingPositionsTodayValueHigherThanYesterday() ) fiveMinutesBeforeMarketCloseEventHandler_openThisPosition( ! signedTicker ); else fiveMinutesBeforeMarketCloseEventHandler_openOppositePosition( ! signedTicker ); } private void fiveMinutesBeforeMarketCloseEventHandler_openPositions() { // this.chosenTickers.SetTickers( this.bestPerformingTickers , this.account ); ! foreach ( string signedTicker in ! this.wFLagChosenPositions.PortfolioPositions.Keys ) this.fiveMinutesBeforeMarketCloseEventHandler_openPosition( ! signedTicker ); } public void FiveMinutesBeforeMarketCloseEventHandler( --- 108,158 ---- return returnValue; } ! private long getQuantity( WeightedPosition weightedPosition ) { double accountValue = this.account.GetMarketValue(); double currentTickerAsk = ! this.account.DataStreamer.GetCurrentAsk( weightedPosition.Ticker ); double maxPositionValueForThisTicker = ! accountValue * Math.Abs( weightedPosition.Weight ); long quantity = Convert.ToInt64( Math.Floor( maxPositionValueForThisTicker / currentTickerAsk ) ); return quantity; } ! private void openPosition( WeightedPosition weightedPosition ) { ! long quantity = this.getQuantity( weightedPosition ); ! OrderType orderType = weightedPosition.GetOrderType(); ! Order order = new Order( ! orderType , new Instrument( weightedPosition.Ticker ) , quantity ); this.account.AddOrder( order ); } private void fiveMinutesBeforeMarketCloseEventHandler_openThisPosition( ! WeightedPosition weightedPosition ) { ! this.openPosition( weightedPosition ); } private void fiveMinutesBeforeMarketCloseEventHandler_openOppositePosition( ! WeightedPosition weightedPosition ) { this.fiveMinutesBeforeMarketCloseEventHandler_openThisPosition( ! weightedPosition.GetOppositeWeightedPosition() ); } private void fiveMinutesBeforeMarketCloseEventHandler_openPosition( ! WeightedPosition weightedPosition ) { if ( this.isDrivingPositionsTodayValueHigherThanYesterday() ) fiveMinutesBeforeMarketCloseEventHandler_openThisPosition( ! weightedPosition ); else fiveMinutesBeforeMarketCloseEventHandler_openOppositePosition( ! weightedPosition ); } private void fiveMinutesBeforeMarketCloseEventHandler_openPositions() { // this.chosenTickers.SetTickers( this.bestPerformingTickers , this.account ); ! foreach ( WeightedPosition weightedPosition in ! this.wFLagChosenPositions.PortfolioWeightedPositions.Values ) this.fiveMinutesBeforeMarketCloseEventHandler_openPosition( ! weightedPosition ); } public void FiveMinutesBeforeMarketCloseEventHandler( |