Ejemplo n.º 1
0
int testFileStoreNewOrderSingle( int count )
{
  FIX::BeginString beginString( FIX::BeginString_FIX42 );
  FIX::SenderCompID senderCompID( "SENDER" );
  FIX::TargetCompID targetCompID( "TARGET" );
  FIX::SessionID id( beginString, senderCompID, targetCompID );

  FIX::ClOrdID clOrdID( "ORDERID" );
  FIX::HandlInst handlInst( '1' );
  FIX::Symbol symbol( "LNUX" );
  FIX::Side side( FIX::Side_BUY );
  FIX::TransactTime transactTime;
  FIX::OrdType ordType( FIX::OrdType_MARKET );
  FIX42::NewOrderSingle message
  ( clOrdID, handlInst, symbol, side, transactTime, ordType );
  message.getHeader().set( FIX::MsgSeqNum( 1 ) );
  std::string messageString = message.toString();

  FIX::FileStore store( "store", id );
  store.reset();
  count = count - 1;

  int start = GetTickCount();
  for ( int i = 0; i <= count; ++i )
  {
    store.set( ++i, messageString );
  }
  int end = GetTickCount();
  store.reset();
  return end - start;
}
Ejemplo n.º 2
0
int testSerializeToStringNewOrderSingle( int count )
{
  FIX::ClOrdID clOrdID( "ORDERID" );
  FIX::HandlInst handlInst( '1' );
  FIX::Symbol symbol( "LNUX" );
  FIX::Side side( FIX::Side_BUY );
  FIX::TransactTime transactTime;
  FIX::OrdType ordType( FIX::OrdType_MARKET );
  FIX42::NewOrderSingle message
  ( clOrdID, handlInst, symbol, side, transactTime, ordType );

  count = count - 1;

  int start = GetTickCount();
  for ( int i = 0; i <= count; ++i )
  {
    message.toString();
  }
  return GetTickCount() - start;
}
Ejemplo n.º 3
0
Archivo: pt.cpp Proyecto: Bobain/pyb
long testSerializeFromStringAndValidateNewOrderSingle( int count )
{
  FIX::ClOrdID clOrdID( "ORDERID" );
  FIX::HandlInst handlInst( '1' );
  FIX::Symbol symbol( "LNUX" );
  FIX::Side side( FIX::Side_BUY );
  FIX::TransactTime transactTime;
  FIX::OrdType ordType( FIX::OrdType_MARKET );
  FIX42::NewOrderSingle message
    ( clOrdID, handlInst, symbol, side, transactTime, ordType );
  std::string string = message.toString();

  count = count - 1;

  long start = GetTickCount();
  for ( int i = 0; i <= count; ++i )
  {
    message.setString( string, VALIDATE, s_dataDictionary.get() );
  }
  return GetTickCount() - start;
}
Ejemplo n.º 4
0
void Application::onMessage( const FIX42::NewOrderSingle& message,
                             const FIX::SessionID& sessionID )
{
  FIX::Symbol symbol;
  FIX::Side side;
  FIX::OrdType ordType;
  FIX::OrderQty orderQty;
  FIX::Price price;
  FIX::ClOrdID clOrdID;
  FIX::Account account;

  message.get( ordType );

  if ( ordType != FIX::OrdType_LIMIT )
    throw FIX::IncorrectTagValue( ordType.getField() );

  message.get( symbol );
  message.get( side );
  message.get( orderQty );
  message.get( price );
  message.get( clOrdID );

  FIX42::ExecutionReport executionReport = FIX42::ExecutionReport
      ( FIX::OrderID( genOrderID() ),
        FIX::ExecID( genExecID() ),
        FIX::ExecTransType( FIX::ExecTransType_NEW ),
        FIX::ExecType( FIX::ExecType_FILL ),
        FIX::OrdStatus( FIX::OrdStatus_FILLED ),
        symbol,
        side,
        FIX::LeavesQty( 0 ),
        FIX::CumQty( orderQty ),
        FIX::AvgPx( price ) );

  executionReport.set( clOrdID );
  executionReport.set( orderQty );
  executionReport.set( FIX::LastShares( orderQty ) );
  executionReport.set( FIX::LastPx( price ) );

  if( message.isSet(account) )
    executionReport.setField( message.get(account) );

  try
  {
    FIX::Session::sendToTarget( executionReport, sessionID );
  }
  catch ( FIX::SessionNotFound& ) {}
}
Ejemplo n.º 5
0
Archivo: pt.cpp Proyecto: Bobain/pyb
long testValidateDictNewOrderSingle( int count )
{
  FIX::ClOrdID clOrdID( "ORDERID" );
  FIX::HandlInst handlInst( '1' );
  FIX::Symbol symbol( "LNUX" );
  FIX::Side side( FIX::Side_BUY );
  FIX::TransactTime transactTime;
  FIX::OrdType ordType( FIX::OrdType_MARKET );
  FIX42::NewOrderSingle message
  ( clOrdID, handlInst, symbol, side, transactTime, ordType );
  message.getHeader().set( FIX::SenderCompID( "SENDER" ) );
  message.getHeader().set( FIX::TargetCompID( "TARGET" ) );
  message.getHeader().set( FIX::MsgSeqNum( 1 ) );

  count = count - 1;

  long start = GetTickCount();
  for ( int i = 0; i <= count; ++i )
  {
    s_dataDictionary->validate( message );
  }
  return GetTickCount() - start;
}
Ejemplo n.º 6
0
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() );
  }
}
Ejemplo n.º 7
0
void Application::sendOrder(SimpleOrder order){


  if(order.orderQty >  0.0 && order.price >  0.0){
	  FIX42::NewOrderSingle newOrderSingle;
	  newOrderSingle.set( order.clOrdID );
	  newOrderSingle.set(FIX::HandlInst( '1' ));
	  newOrderSingle.set( order.symbol );
	  newOrderSingle.set( order.side );
	  newOrderSingle.set(FIX::TransactTime());
	  newOrderSingle.set( FIX::OrdType( FIX::OrdType_LIMIT ) );
	  newOrderSingle.set( order.orderQty );
	  newOrderSingle.set( FIX::TimeInForce( FIX::TimeInForce_DAY ) );
	  newOrderSingle.set( order.price );
	  setHeader( newOrderSingle.getHeader() );
	  FIX::Session::sendToTarget( newOrderSingle );
  }else{
	//std::cout << "[Application::sendOrder] NOT SENT!!!"<<std::endl;
  	 }


}
Ejemplo n.º 8
0
  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 ) ;
  }