Exemple #1
0
        public MockupManager()
        {
            if (MockupManager.StrategyDictionary == null)
            {
                MockupManager.StrategyDictionary = new Dictionary<string, Strategy>();
                StrategyOrderList = new List<StrategyOrderInfo>();

                StrategyDictionary["ST1"] = new Strategy() { StrategyId = "ST1", StrategyName = "Q Strategy 1" };
                StrategyDictionary["ST2"] = new Strategy() { StrategyId = "ST2", StrategyName = "Q Strategy 2" };
                StrategyDictionary["ST3"] = new Strategy() { StrategyId = "ST3", StrategyName = "Q Strategy 3" };
                StrategyDictionary["ST4"] = new Strategy() { StrategyId = "ST4", StrategyName = "Q Strategy 4" };

                StrategyOrderInfo order1 = new StrategyOrderInfo(StrategyDictionary["ST1"], "BAC", "Trading", 112.12, 2.5, -300, 104.93, 2, 153879, 0.00073, 100, 250.00, 1000, 10000);
                StrategyOrderInfo order2 = new StrategyOrderInfo(StrategyDictionary["ST1"], "AMD", "Trading", -1.23, 2.5, 100, 9.02, 3, 70200, -0.00002, 25.00, 2.00, 5000, 5000);
                StrategyOrderInfo order3 = new StrategyOrderInfo(StrategyDictionary["ST1"], "MSFT", "Stopped", 0.45, 0.55, 250, 89.21, 1, 10100, 0.00000, -78.00, 45.56, 1000, 500);
                StrategyOrderInfo order4 = new StrategyOrderInfo(StrategyDictionary["ST1"], "LVLT", "Max_Loss", 9.99, 2.5, 200, 70.10, 1, 98000, 0.00010, 2.00, 120.40, 100, 8500);
                StrategyOrderInfo order5 = new StrategyOrderInfo(StrategyDictionary["ST1"], "INTC", "Trading", 3.45, 2.5, 0, 114.32, 0, 112352, 0.00003, 13.00, -2.45, 100, 24300);
                StrategyOrderInfo order6 = new StrategyOrderInfo(StrategyDictionary["ST1"], "QQQQ", "Trading", -1.23, 2.5, -200, 41.20, 2, 65850, 0.00002, 5.00, 1.99, 100, 1000);

                StrategyOrderList.Add(order1);
                StrategyOrderList.Add(order2);
                StrategyOrderList.Add(order3);
                StrategyOrderList.Add(order4);
                StrategyOrderList.Add(order5);
                StrategyOrderList.Add(order6);
            }
        }
Exemple #2
0
        public SummaryOrder(StrategyOrderInfo strategyOrderInfo)
        {
            this.StrategyId = strategyOrderInfo.Strategy.StrategyId;
            this.StrategyName = strategyOrderInfo.Strategy.StrategyName;
            this.Status = App.AppManager.StgEngine.StrategyEngineStatus;
            this.TotalCount = 1;
            this.TradingCount = 0;
            if (strategyOrderInfo.Status.Equals("Trading"))
            {
                this.TradingCount = 1;
            }

            this.Status = App.AppManager.StgEngine.StrategyEngineStatus;
            this.SymbolTrading = string.Format("{0} of {1}", this.TradingCount, this.TotalCount);
            this.PnL = strategyOrderInfo.PnL;
            this.UR_PnL = strategyOrderInfo.UR_PnL;
            this.PositionShares = strategyOrderInfo.Position_Shares;
            this.PositionAmount = strategyOrderInfo.Position_Amount;
            this.OpenOrders = strategyOrderInfo.Number_Of_Open_Orders;
            this.Volume = strategyOrderInfo.Volume;
            this.TradingRevenue = strategyOrderInfo.Trading_Revenue;
            this.RebateRevenue = strategyOrderInfo.Rebate_Revenue;
            this.MaxLoss = strategyOrderInfo.Max_Loss;
            this.SeedRemaining = strategyOrderInfo.SeedRemaining;
        }
Exemple #3
0
 public static void AddNew(int count)
 {
     int oldCount = StrategyOrderList.Count;
     int newCount = oldCount + count;
     for (int x = oldCount; x < newCount; x++)
     {
         string symbol = "SYMBOL_"+ (x+1).ToString();
         StrategyOrderInfo order1 = new StrategyOrderInfo(StrategyDictionary["ST1"], symbol, "Trading", 112.12, 2.5, -300, 104.93, 2, 153879, 0.00073, 100, 250.00, 1000, 10000);
         StrategyOrderList.Add(order1);
     }
 }
        public void UpdateSummaryRow(ItemCollection _itemCollection)
        {
            StrategyOrderInfo summaryRow = new StrategyOrderInfo();
            summaryRow.IsSummaryRow = true;
            summaryRow.Symbol = "Totals:";
            for (int i = 0; i < _itemCollection.Count; i++)
            {
                StrategyOrderInfo orderInfo = _itemCollection[i] as StrategyOrderInfo;
                if (orderInfo != null)
                {
                    summaryRow.Max_Loss += orderInfo.Max_Loss;
                    summaryRow.Number_Of_Open_Orders += orderInfo.Number_Of_Open_Orders;
                    summaryRow.PnL += orderInfo.PnL;
                    summaryRow.UR_PnL += orderInfo.UR_PnL;
                    summaryRow.Position_Shares += orderInfo.Position_Shares;
                    summaryRow.Position_Amount += orderInfo.Position_Amount;
                    summaryRow.Rebate_Revenue += orderInfo.Rebate_Revenue;
                    summaryRow.SeedRemaining += orderInfo.SeedRemaining;
                    summaryRow.Trading_Revenue += orderInfo.Trading_Revenue;
                    summaryRow.Volume += orderInfo.Volume;
                }
            }

            if (summaryRow.Volume != 0)
            {
                summaryRow.PnL_Per_Share = summaryRow.PnL / summaryRow.Volume;
            }
            else
            {
                summaryRow.PnL_Per_Share = 0;
            }

            App.AppManager.RunOnDispatcherThread(() =>
            {
                if (App.AppManager.DataMgr.AggregateStrategyOrderInfo.Count > 0)
                {
                    App.AppManager.DataMgr.AggregateStrategyOrderInfo[0] = summaryRow;
                }
                //App.AppManager.DataMgr.AggregateStrategyOrderInfo.Clear();
                //App.AppManager.DataMgr.AggregateStrategyOrderInfo.Add(summaryRow);
            });
        }
Exemple #5
0
        internal void Update(StrategyOrderInfo oldStrategyOrderInfo, StrategyOrderInfo strategyOrderInfo)
        {
            if (oldStrategyOrderInfo != null)
            {
                if (oldStrategyOrderInfo.Status.Equals("Trading"))
                {
                    this.TradingCount = this.TradingCount - 1;
                }
                this.TotalCount -= 1;
                this.PnL -= oldStrategyOrderInfo.PnL;
                this.UR_PnL -= oldStrategyOrderInfo.UR_PnL;
                this.PositionShares -= oldStrategyOrderInfo.Position_Shares;
                this.PositionAmount -= oldStrategyOrderInfo.Position_Amount;
                this.Volume -= oldStrategyOrderInfo.Volume;
                this.OpenOrders -= oldStrategyOrderInfo.Number_Of_Open_Orders;
                this.TradingRevenue -= oldStrategyOrderInfo.Trading_Revenue;
                this.RebateRevenue -= oldStrategyOrderInfo.Rebate_Revenue;
                this.MaxLoss -= oldStrategyOrderInfo.Max_Loss;
                this.SeedRemaining -= oldStrategyOrderInfo.SeedRemaining;
            }

            this.StrategyName = strategyOrderInfo.Strategy.StrategyName;
            this.TotalCount += 1;
            if (strategyOrderInfo.Status.Equals("Trading"))
            {
                this.TradingCount = this.TradingCount + 1;
            }

            if (App.AppManager != null)
            {
                this.Status = App.AppManager.StgEngine.StrategyEngineStatus;
                this.SymbolTrading = string.Format("{0} of {1}", this.TradingCount, this.TotalCount);
                this.PnL += strategyOrderInfo.PnL;
                this.UR_PnL += strategyOrderInfo.UR_PnL;
                this.PositionShares += strategyOrderInfo.Position_Shares;
                this.PositionAmount += strategyOrderInfo.Position_Amount;
                this.OpenOrders += strategyOrderInfo.Number_Of_Open_Orders;
                this.Volume += strategyOrderInfo.Volume;
                this.TradingRevenue += strategyOrderInfo.Trading_Revenue;
                this.RebateRevenue += strategyOrderInfo.Rebate_Revenue;
                this.MaxLoss += strategyOrderInfo.Max_Loss;
                this.SeedRemaining += strategyOrderInfo.SeedRemaining;
            }
        }
 private static void ProcessOrder(ProcessType _processType, StrategyOrderInfo order)
 {
     switch (_processType)
     {
         case ProcessType.START: order.Status = "Trading"; break;
         case ProcessType.STOP: order.Status = "Stopped"; break;
         case ProcessType.LOCK: order.Status = "Locked"; break;
         case ProcessType.UNLOCK: order.Status = "Stopped"; break;
         case ProcessType.CANCELALL: order.Status = "Hung"; break;
         case ProcessType.UNWIND: order.Status = "MaxLoss"; break;
         default: break;
     }
 }
 public void Update(StrategyOrderInfo strategyOrderInfo)
 {
     this.Strategy.StrategyId = strategyOrderInfo.Strategy.StrategyId;
     this.Strategy.StrategyName = strategyOrderInfo.Strategy.StrategyName;
     this.Symbol = strategyOrderInfo.Symbol;
     this.Status = strategyOrderInfo.Status;
     this.TradingMode = strategyOrderInfo.TradingMode;
     this.PnL = strategyOrderInfo.PnL;
     this.UR_PnL = strategyOrderInfo.UR_PnL;
     this.Position_Shares = strategyOrderInfo.Position_Shares;
     this.Position_Amount = strategyOrderInfo.Position_Amount;
     this.Number_Of_Open_Orders = strategyOrderInfo.Number_Of_Open_Orders;
     this.Volume = strategyOrderInfo.Volume;
     this.Trading_Revenue = strategyOrderInfo.Trading_Revenue;
     this.Rebate_Revenue = strategyOrderInfo.Rebate_Revenue;
     this.Max_Loss = strategyOrderInfo.Max_Loss;
     this.SeedRemaining = strategyOrderInfo.SeedRemaining;
     this.User_Message = strategyOrderInfo.User_Message;
     this.InProcess = false;
 }
Exemple #8
0
        internal void UpdateStrategyData(List<StrategyOrderInfo> updateOrderList, bool IsSendProcessReponse)
        {
            string logMessage = string.Format("Class: {0}, Method: {1}", "DataManager", "UpdateStrategyData(..)");
            LogUtil.WriteLog(LogLevel.INFO, logMessage);

            updateOrderList = updateOrderList.OrderBy(s => s.Strategy.StrategyName).ToList();
            for (int i = 0; i < updateOrderList.Count; i++)
            {
                string symbolKey = updateOrderList[i].Symbol;
                string strategyIdKey = updateOrderList[i].Strategy.StrategyId;

                //oldStrategyInfo: To hold the value of existing order, so it will use in running summary-calculation,
                //to subtract the values, before adding the new values
                StrategyOrderInfo oldStrategyInfo = new StrategyOrderInfo();

                if (!this.StrategyOrderDictionary.ContainsKey(strategyIdKey))
                {
                    this.StrategyOrderDictionary[strategyIdKey] = new ConcurrentDictionary<string,StrategyOrderInfo>();
                }

                if (this.StrategyOrderDictionary[strategyIdKey].ContainsKey(symbolKey))
                {
                    StrategyOrderInfo existingStrategyOrder = this.StrategyOrderDictionary[strategyIdKey][symbolKey];
                    if (existingStrategyOrder.InProcess == true && !IsSendProcessReponse)
                    {
                        //Since row is in send process, therefore auto-update should not modify
                    }
                    else
                    {
                        oldStrategyInfo.Update(existingStrategyOrder); //Clone the values of existingStrategyOrder
                        existingStrategyOrder.Update(updateOrderList[i]); // Update with new values
                        ModifyListCollectionView(strategyIdKey, symbolKey, "EDIT");
                        ModifyStrategyStatusListCollectionView(strategyIdKey, symbolKey, "EDIT");
                    }
                }
                else
                {
                    oldStrategyInfo = null;
                    this.StrategyOrderDictionary[strategyIdKey][symbolKey] = updateOrderList[i];
                    RunOnDispatcherThread((Action)(() =>
                    {
                        if (!this.StrategyList.Any(s => s.StrategyId == updateOrderList[i].Strategy.StrategyId))
                        {
                            this.StrategyList.Add(new Strategy(updateOrderList[i].Strategy.StrategyId, updateOrderList[i].Strategy.StrategyName));
                        }
                    }));
                    ModifyListCollectionView(strategyIdKey, symbolKey, "NEW");
                    ModifyStrategyStatusListCollectionView(strategyIdKey, symbolKey, "NEW");

                }

                if (this.SummaryOrderDictionary.ContainsKey(strategyIdKey))
                {
                    if (this.StrategyOrderDictionary[strategyIdKey][symbolKey].InProcess == true && !IsSendProcessReponse)
                    {
                        //Since row is in send process, therefore auto-update should not modify summary Row
                    }
                    else
                    {
                        this.SummaryOrderDictionary[strategyIdKey].Update(oldStrategyInfo, updateOrderList[i]);
                        ModifySummaryListCollectionView(strategyIdKey, "EDIT");
                    }
                }
                else
                {
                    this.SummaryOrderDictionary[strategyIdKey] = new SummaryOrder(updateOrderList[i]);
                    ModifySummaryListCollectionView(strategyIdKey, "NEW");
                }
            }

            if (this.DataUpdateCompleted != null)
            {
                this.DataUpdateCompleted(this, new EventArgs());
            }
        }