Example #1
0
        public TradeSecurityResponse TradeSecurity(TradeSecurityRequest trade)
        {
            try
            {
                //Embedded rules
                if (trade.Participant != "ABC")
                {
                    throw new ArgumentException("Particpant must be \"ABC\"");
                }

                if (trade.Publisher != "XYZ")
                {
                    throw new ArgumentException("Publisher must be \"XYZ\"");
                }

                if (trade.Ticker != "MSFT")
                {
                    throw new ArgumentException("Ticker must be \"MSFT\"");
                }


                //Quantity check
                if (trade.TradeItem.Quantity < 1)
                {
                    throw new ArgumentException("Bad Quantity on Trade");
                }

                Execution execution = null;

                switch (trade.TradeItem.Ticker.ToLower())
                {
                case "ibm":
                    execution = ExecuteTrade(trade.TradeItem, IBM_Price);
                    break;

                case "msft":
                    execution = ExecuteTrade(trade.TradeItem, MSFT_Price);
                    break;

                default:
                    throw new ArgumentException(
                              "Don't know - only MSFT & IBM", "ticker");
                }

                TradeSecurityResponse response = new TradeSecurityResponse();
                response.ExecutionReport = execution;
                return(response);
            }
            catch (ArgumentException ex)
            {
                throw new FaultException <ArgumentException>(ex);
            }
        }
Example #2
0
        public TradeSecurityResponse TradeSecurity( TradeSecurityRequest trade )
        {
            try
            {
                //Embedded rules
                if( trade.Participant != "ABC" )
                    throw new ArgumentException( "Particpant must be \"ABC\"" );

                if( trade.Publisher != "XYZ" )
                    throw new ArgumentException( "Publisher must be \"XYZ\"" );
                
                if( trade.Ticker != "MSFT" )
                    throw new ArgumentException( "Ticker must be \"MSFT\"" );
                

                //Quantity check
                if( trade.TradeItem.Quantity < 1 )
                    throw new ArgumentException( "Bad Quantity on Trade" );

                Execution execution = null;

                switch( trade.TradeItem.Ticker.ToLower() )
                {
                    case "ibm":
                        execution = ExecuteTrade( trade.TradeItem, IBM_Price );
                        break;
                    case "msft":
                        execution = ExecuteTrade( trade.TradeItem, MSFT_Price );
                        break;
                    default:
                        throw new ArgumentException(
                            "Don't know - only MSFT & IBM", "ticker" );
                }

                TradeSecurityResponse response = new TradeSecurityResponse();
                response.ExecutionReport = execution;
                return response;
            }
            catch( ArgumentException ex )
            {
                throw new FaultException<ArgumentException>( ex );
            }
        }