[Quantproject-developers] QuantProject/b4_Business/a2_Strategies AccountManager.cs, 1.7, 1.8
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2009-08-30 15:42:31
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv21865/b4_Business/a2_Strategies Modified Files: AccountManager.cs Log Message: Added overload for OpenPositions method, in order to use leverage Index: AccountManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/AccountManager.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** AccountManager.cs 13 Dec 2008 17:15:35 -0000 1.7 --- AccountManager.cs 30 Aug 2009 15:42:18 -0000 1.8 *************** *** 93,96 **** --- 93,112 ---- Account account, double initialCashIfTheAccountIsEmpty) { + OpenPositions(weightedPositions, account, initialCashIfTheAccountIsEmpty, 1); + } + + /// <summary> + /// Modifies the state for the given account, + /// opening positions provided by the given weightedPositions + /// </summary> + /// <param name="weightedPositions"></param> + /// <param name="account"></param> + /// <param name="initialCashForTheAccount">The initial cash for the account + /// <param name="leverage">It multiplies initial cash in order to compute + /// value to invest in the given weighted positions</param> + static public void OpenPositions(WeightedPositions weightedPositions, + Account account, double initialCashIfTheAccountIsEmpty, + double leverage) + { if(account.Transactions.Count == 0) account.AddCash(initialCashIfTheAccountIsEmpty); *************** *** 98,102 **** throw new Exception("Both parameters have to be set to valid objects!"); orders.Clear(); ! double valueToInvestInPositions = account.CashAmount; foreach(WeightedPosition weightedPosition in weightedPositions.Values) addWeightedPositionToOrderList( weightedPosition, account, valueToInvestInPositions ); --- 114,118 ---- throw new Exception("Both parameters have to be set to valid objects!"); orders.Clear(); ! double valueToInvestInPositions = account.CashAmount * leverage; foreach(WeightedPosition weightedPosition in weightedPositions.Values) addWeightedPositionToOrderList( weightedPosition, account, valueToInvestInPositions ); |