[Quantproject-developers] QuantProject/b4_Business/a2_Strategies AccountManager.cs, 1.3, 1.4
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2008-01-14 23:23:09
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv14515/b4_Business/a2_Strategies Modified Files: AccountManager.cs Log Message: Code has been reorganised in a more logical way Index: AccountManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/AccountManager.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AccountManager.cs 23 Sep 2007 21:53:20 -0000 1.3 --- AccountManager.cs 14 Jan 2008 23:23:05 -0000 1.4 *************** *** 102,108 **** #endregion ! #region ReversePositions ! ! static private double reversePositions_getReversedWeightedPositionsFromAccount_getPositionsAbsoluteValue(Account account) { double totalValue = 0; --- 102,106 ---- #endregion ! static private double getWeightedPositions_getPositionsAbsoluteValue(Account account) { double totalValue = 0; *************** *** 111,119 **** position.Instrument.Key ) * position.Quantity ); return totalValue; ! } ! static private WeightedPositions reversePositions_getReversedWeightedPositionsFromAccount(Account account) { ! double positionsAbsoluteValue = reversePositions_getReversedWeightedPositionsFromAccount_getPositionsAbsoluteValue(account); string[] tickers = getTickersInOpenedPositions( account ); double[] weights = new double[tickers.Length]; --- 109,120 ---- position.Instrument.Key ) * position.Quantity ); return totalValue; ! } ! /// <summary> ! /// Gets the current open WeightedPositions for the given account ! /// </summary> ! static public WeightedPositions GetWeightedPositions(Account account) { ! double positionsAbsoluteValue = getWeightedPositions_getPositionsAbsoluteValue(account); string[] tickers = getTickersInOpenedPositions( account ); double[] weights = new double[tickers.Length]; *************** *** 121,141 **** weights[i] = ( account.GetMarketValue( tickers[i] )* ! account.Portfolio.GetPosition( tickers[i] ).Quantity ) / positionsAbsoluteValue; ! WeightedPositions returnValue = new WeightedPositions( weights, tickers ); ! returnValue.Reverse(); ! return returnValue; ! } ! static public void ReversePositions(Account account) { orders.Clear(); ! WeightedPositions reversedWeightedPositions = ! reversePositions_getReversedWeightedPositionsFromAccount( account ); ClosePositions(account); ! OpenPositions( reversedWeightedPositions , account ); } - #endregion - } // end of class } --- 122,139 ---- weights[i] = ( account.GetMarketValue( tickers[i] )* ! account.Portfolio.GetPosition( tickers[i] ).Quantity ) / positionsAbsoluteValue; ! ! return new WeightedPositions( weights, tickers ); ! } ! static public void ReversePositions(Account account) { orders.Clear(); ! WeightedPositions currentWeightedPositions = GetWeightedPositions( account ); ! currentWeightedPositions.Reverse(); ClosePositions(account); ! OpenPositions( currentWeightedPositions, account ); } } // end of class } |