void RequestApplication::onMessage ( const FIX42::NewOrderSingle &newOrder, const FIX::SessionID &sessionId ) { FIX::Side lSide ; newOrder.getField( lSide ) ; FIX::OrdType lOrdType ; newOrder.getField( lOrdType ) ; FIX::OrderQty lOrderQty ; newOrder.getField( lOrderQty ) ; NewOrderPtr order( new NewOrder( newOrder.getField( FIX::FIELD::SecurityID ), newOrder.getField( FIX::FIELD::ClOrdID ), sessionId.toString(), FromFix::convert( lSide ), FromFix::convert( lOrdType ), lOrderQty ) ) ; try { FIX::TimeInForce lTimeInForce; if( newOrder.isSetField( lTimeInForce ) ) { newOrder.getField( lTimeInForce ); order->setTimeInForce( FromFix::convert( lTimeInForce ) ) ; } }catch( std::exception &e ) {} FIX::MaxFloor lMaxFloor ; if( newOrder.isSetField( lMaxFloor ) ) { newOrder.getField( lMaxFloor ) ; order->setDisclosedQty( lMaxFloor ) ; } switch( order->getOrderType() ) { case OrderType_LIMIT : { FIX::Price lPrice ; newOrder.getField( lPrice ) ; order->setPrice( lPrice ) ; } break ; case OrderType_STOP_LIMIT : { FIX::Price lPrice ; newOrder.getField( lPrice ) ; order->setPrice( lPrice ) ; } // No break here case OrderType_STOP : { FIX::StopPx lStopPx ; newOrder.getField( lStopPx ) ; order->setStopPrice( lStopPx ) ; } break ; case OrderType_MARKET : break ; } _market.insert( order ) ; }
void Application::onMessage( const FIX42::NewOrderSingle& message, const FIX::SessionID& ) { FIX::SenderCompID senderCompID; FIX::TargetCompID targetCompID; FIX::ClOrdID clOrdID; FIX::Symbol symbol; FIX::Side side; FIX::OrdType ordType; FIX::Price price; FIX::OrderQty orderQty; FIX::TimeInForce timeInForce( FIX::TimeInForce_DAY ); message.getHeader().get( senderCompID ); message.getHeader().get( targetCompID ); message.get( clOrdID ); message.get( symbol ); message.get( side ); message.get( ordType ); if ( ordType == FIX::OrdType_LIMIT ) message.get( price ); message.get( orderQty ); if ( message.isSetField( timeInForce ) ) message.get( timeInForce ); try { if ( timeInForce != FIX::TimeInForce_DAY ) throw std::logic_error( "Unsupported TIF, use Day" ); Order order( clOrdID, symbol, senderCompID, targetCompID, convert( side ), convert( ordType ), price, (long)orderQty ); processOrder( order ); } catch ( std::exception & e ) { rejectOrder( senderCompID, targetCompID, clOrdID, symbol, side, e.what() ); } }