Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22160/b4_Business/a1_Financial/a2_Accounting
Modified Files:
Account.cs
Log Message:
The AddOrder method has been improved:
- an exception is thrown when a sell order for an instrument is submitted, but no long position is held for that ticker
- an exception is thrown when a cover order for an instrument is submitted, but no short position is held for that ticker
Index: Account.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/Account.cs,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** Account.cs 3 Aug 2005 18:55:10 -0000 1.20
--- Account.cs 26 Nov 2005 23:49:21 -0000 1.21
***************
*** 195,200 ****
--- 195,214 ----
}
+ private void addOrder_throwExceptions( Order order )
+ {
+ if ( ( ( order.Type == OrderType.MarketSell ) ||
+ ( order.Type == OrderType.LimitSell ) ) &&
+ ( !this.Portfolio.IsLong( order.Instrument.Key ) ) )
+ throw new Exception( "A sell order has been submitted, but this " +
+ "account doesn't contain a long position for this ticker" );
+ if ( ( ( order.Type == OrderType.MarketCover ) ||
+ ( order.Type == OrderType.LimitCover ) ) &&
+ ( !this.Portfolio.IsShort( order.Instrument.Key ) ) )
+ throw new Exception( "A cover order has been submitted, but this " +
+ "account doesn't contain a short position for this ticker" );
+ }
public void AddOrder( Order order )
{
+ this.addOrder_throwExceptions( order );
this.orderExecutor.Execute( order );
}
|