Example #1
0
 public override void onExecutionReport(ExecutionReport report)
 {
     Console.WriteLine("Got on onExecutionReport Event.");
     report.dump();
     Console.WriteLine("Status = %d", OrderStatus.OrderStatus_CONFIRMED);
     if (report.getInstrumentName() == (_data.firstLegSymbol))
     {
         if (report.getOrderStatus() == OrderStatus.OrderStatus_CONFIRMED ||
             report.getOrderStatus() == OrderStatus.OrderStatus_REPLACED)
         {
             _data.firstLegOrder.setClOrdId(report.getClOrderId());
             _data.firstLegOrder.setOrigClOrdId(report.getOriginalClOrderId());
             _data.firstLegOrder.setOrderStatus(OrderStatus.OrderStatus_CONFIRMED);
             _data.isOrderPending = false;
         }
         else if (report.getOrderStatus() == OrderStatus.OrderStatus_FILLED)
         {
             placeSecondLegMarket();
             _data.isOrderPending = false;
         }
     }
     else if (report.getInstrumentName() == (_data.secondLegSymbol))
     {
         if (report.getOrderStatus() == OrderStatus.OrderStatus_CONFIRMED)
         {
             _data.secondLegOrder.setClOrdId(report.getClOrderId());
             _data.secondLegOrder.setOrigClOrdId(report.getOriginalClOrderId());
             _data.isOrderPending = false;
         }
         else if (report.getOrderStatus() == OrderStatus.OrderStatus_FILLED)
         {
             Console.WriteLine("Strategy completed successfully.");
         }
     }
 }
Example #2
0
        public override void onExecutionReport(ExecutionReport report)
        {
            logInfo("onExecutionReport:-------------------->");
            //		report.dump();
            try{
                logInfo("Status:" + report.getOrderStatus().ToString());
                logInfo("Instrument Name: " + report.getInstrumentName());


                printOrder(
                    Portfolio.getInstance().getOrderBook().getOrder(
                        report.getClOrderId()
                        )
                    );
            }
            catch (Exception e)
            {
                logInfo(e.Message);
            }
            logInfo("Status:" + report.getOrderStatus().ToString());
            logInfo("Instrument Name: " + report.getInstrumentName());


            if (report.getInstrumentName() == (sd.firstLegSymbol))
            {
                logInfo("Here1");
                if (report.getOrderStatus() == (OrderStatus.OrderStatus_CONFIRMED))
                {
                    logInfo("Here2");
                    sd.firstLegOrder.setClOrdId(report.getClOrderId());
                    sd.firstLegOrder.setOrigClOrdId(report.getOriginalClOrderId());
                    sd.firstLegOrder.setOrderStatus(OrderStatus.OrderStatus_CONFIRMED);
                    sd.isOrderPending = false;
                }
                else if (report.getOrderStatus() == (OrderStatus.OrderStatus_REPLACED))
                {
                    sd.firstLegOrder.setClOrdId(report.getClOrderId());
                    sd.firstLegOrder.setOrigClOrdId(report.getOriginalClOrderId());
                    sd.firstLegOrder.setOrderStatus(OrderStatus.OrderStatus_CONFIRMED);
                    sd.isOrderPending = false;
                }
                else if (report.getOrderStatus() == (OrderStatus.OrderStatus_FILLED))
                {
                    try
                    {
                        TradeQue trades
                            = Portfolio.getInstance().getTradeBook().getTradeQue(report.getClOrderId());
                        logInfo("**************** Dumping Trades ***************** .\n");
                        long size = trades.size();
                        logInfo("size = ", size);
                        for (int i = 0; i < size; ++i)
                        {
                            printTrade(trades.getitem(i));
                        }
                    }
                    catch (Exception e)
                    {
                        logInfo(e.Message.ToString());
                    }
                    //				Side side;
                    //				if(report.getOrderMode().)
                    //
                    //
                    placeSecondLegMarket();
                    sd.isOrderPending = true;
                    //				Position pos =Portfolio.getInstance().getNetPositions().getPosition(
                    //						Context.getInstance().getInstrument(report.getInstrumentName()),
                    //						report.getOrderMode());
                    //				printPosition(pos);
                    printPortfolio(report.getInstrumentName(), report.getOrderMode());

                    //				List trades = new ArrayList<Trade>();
                    //				trades =ArrayList<Trade>Portfolio.getInstance().getTradeBook().getTrades(
                    //						report.getClOrderId()
                    //						);
                    //				printTrade((Trade)trades.get(trades.size()-1));
                }
            }
            else if (report.getInstrumentName() == (sd.secondLegSymbol))
            {
                if (report.getOrderStatus() == (OrderStatus.OrderStatus_CONFIRMED))
                {
                    sd.secondLegOrder.setClOrdId(report.getClOrderId());
                    sd.secondLegOrder.setOrigClOrdId(report.getOriginalClOrderId());
                    sd.isOrderPending = false;
                }
                else if (report.getOrderStatus() == (OrderStatus.OrderStatus_FILLED))
                {
                    logInfo("Strategy completed successfully.\n");
                    printPortfolio();
                    logInfo("Calling Logout.\n");
                    Context.getInstance().logout();
                }
            }
        }
Example #3
0
 public override void onExecutionReport(ExecutionReport report)
 {
     Console.WriteLine("Got on onExecutionReport Event.");
     report.dump();
     Console.WriteLine("Status = %d",OrderStatus.OrderStatus_CONFIRMED);
     if(report.getInstrumentName() == (_data.firstLegSymbol))
     {
         if( report.getOrderStatus() == OrderStatus.OrderStatus_CONFIRMED ||
             report.getOrderStatus() == OrderStatus.OrderStatus_REPLACED )
         {
             _data.firstLegOrder.setClOrdId(report.getClOrderId());
             _data.firstLegOrder.setOrigClOrdId(report.getOriginalClOrderId());
             _data.firstLegOrder.setOrderStatus(OrderStatus.OrderStatus_CONFIRMED);
             _data.isOrderPending = false;
         }
         else if(report.getOrderStatus() == OrderStatus.OrderStatus_FILLED)
         {
             placeSecondLegMarket();
             _data.isOrderPending = false;
         }
     }
     else if(report.getInstrumentName() == (_data.secondLegSymbol))
     {
         if(report.getOrderStatus() == OrderStatus.OrderStatus_CONFIRMED)
         {
             _data.secondLegOrder.setClOrdId(report.getClOrderId());
             _data.secondLegOrder.setOrigClOrdId(report.getOriginalClOrderId());
             _data.isOrderPending = false;
         }
         else if(report.getOrderStatus() == OrderStatus.OrderStatus_FILLED)
         {
             Console.WriteLine("Strategy completed successfully.");
         }
     }
 }