Пример #1
0
        private Order createLimitOrder(String buySell, double triggerPrice, int size)
        {
            Order order = AppObjectUtil.createLimitOrder(buySell, triggerPrice, appStgManager.UserAccount, size);

            order.OrderId = appStgManager.ibClient.IncreaseOrderId();
            return(order);
        }
Пример #2
0
        private Order createMktOrder(String buySell, int size)
        {
            Order order = AppObjectUtil.createMktOrder(buySell, appStgManager.UserAccount, size);

            order.OrderId = appStgManager.ibClient.IncreaseOrderId();
            return(order);
        }
Пример #3
0
        private AppOrder createAppOrder(String buySell, String triggerRule, double triggerPrice, String remark, Order order, DateTime currentTimeStamp)
        {
            AppOrder appOrder = AppObjectUtil.createAppOrder(stgName, order, stgIndex);

            appOrder.IBOrder      = order;
            appOrder.TriggerRule  = triggerRule;
            appOrder.TriggerPrice = triggerPrice;
            appOrder.TriggerTime  = currentTimeStamp;
            appOrder.Remark       = remark;
            return(appOrder);
        }
Пример #4
0
 public void cancelPendingTrades()
 {
     IAppOrder[] appOrders = execution.getPendingOrders();
     for (int i = 0; i < appOrders.Length; i++)
     {
         if (appOrders[i] != null && !AppObjectUtil.isOrderClosed(appOrders[i]))
         {
             appStgManager.getOrderManager().CancelOrder(appOrders[i].IBOrder);
         }
     }
 }
Пример #5
0
 public String getCompleteSignalSide()
 {
     if (PendingOrder1 != null && AppObjectUtil.isOrderClosed(PendingOrder1))
     {
         return(PendingSignalSide1);
     }
     if (PendingOrder2 != null && AppObjectUtil.isOrderClosed(PendingOrder2))
     {
         return(PendingSignalSide2);
     }
     return(null);
 }
Пример #6
0
 public int getIndexClosedAppOrder()
 {
     if (PendingOrder1 != null && AppObjectUtil.isOrderClosed(PendingOrder1))
     {
         return(1);
     }
     if (PendingOrder2 != null && AppObjectUtil.isOrderClosed(PendingOrder2))
     {
         return(2);
     }
     return(0);
 }
Пример #7
0
        public IAppOrder getClosedAppOrder()
        {
            IAppOrder tempOrder = null;

            if (PendingOrder1 != null && AppObjectUtil.isOrderClosed(PendingOrder1))
            {
                tempOrder = PendingOrder1;
            }
            if (PendingOrder2 != null && AppObjectUtil.isOrderClosed(PendingOrder2))
            {
                tempOrder = PendingOrder2;
            }
            return(tempOrder);
        }
Пример #8
0
        public void processExecution(ExecutionMessage message)
        {
            IAppOrderManager orderManager = appStgManager.getAppOrderManager();

            String[] stgNames = appStgManager.getStgNames();
            if (!appStgManager.getAppOrderManager().AppOrderStore.ContainsKey(message.Execution.OrderId))
            {
                return;
            }
            if (!orderManager.isExecutionProcessed(message.Execution.ExecId))
            {
                AppExecution execution  = orderManager.updateAppOrderExecution(message);
                IAppOrder    order      = orderManager.AppOrderStore[message.Execution.OrderId];
                AppOrder     cloneOrder = (AppOrder)order.Clone();
                if (AppObjectUtil.isOrderClosed(cloneOrder))
                {
                    orderManager.closeOpenAppOrder(order.StrategyIndex, order);
                }
                orderManager.updatePosition(order.StrategyIndex, execution);
                String      stgName     = stgNames[order.StrategyIndex];
                AppPosition stgPosition = orderManager.StoreStgPositions[stgName];
                log.Info("Total PnL : " + stgPosition.TotalPnL);
                orderManager.markExeProcessed(message.Execution.ExecId);

                //***New for send order executed email***
                IAppEventManager appEventManager = appStgManager.getAppEventManager();
                appEventManager.putOrderExeEvents(message, stgName);

                /*TSAppExecution execution = appForm.StrategyManager.updateAppOrderExecution(message);
                 * TSAppOrder order = appForm.StrategyManager.AppOrderStore[message.Execution.OrderId];
                 * TSAppOrder cloneOrder = (TSAppOrder)order.Clone();
                 * if (StrategyManager.isOrderClosed(cloneOrder))
                 * {
                 *  appForm.StrategyManager.closeOpenAppOrder(order.StrategyIndex, order);
                 *  //appForm.StrategyManager.removeOpenAppOrder(order.StrategyIndex, order);
                 *  //appForm.StrategyManager.addClosedAppOrder(order.StrategyIndex, order);
                 * }
                 * appForm.StrategyManager.updatePosition(order.StrategyIndex, execution);
                 * String stgName = appForm.StrategyManager.StgNames[order.StrategyIndex];
                 * AppPosition stgPosition = appForm.StrategyManager.StoreStgPositions[stgName];
                 * log.Info("Total PnL : " + stgPosition.TotalPnL);
                 * //log.Info("Total PnL : " + appForm.StrategyManager.StgPositions[order.StrategyIndex].TotalPnL);
                 * appForm.StrategyManager.markExeProcessed(message.Execution.ExecId);*/
            }
            log.Info("Order Executed");
            log.Info("*********************************************");
        }
Пример #9
0
        public void cancelPendingTrade(int index)
        {
            IAppOrder tempOrder = null;

            if (index == 1)
            {
                tempOrder = execution.PendingOrder1;
            }
            else
            {
                tempOrder = execution.PendingOrder2;
            }
            if (tempOrder != null && !AppObjectUtil.isOrderClosed(tempOrder))
            {
                appStgManager.getOrderManager().CancelOrder(tempOrder.IBOrder);
            }
        }