Beispiel #1
0
 private bool _CheckAccount(RTDItem item)
 {
     if (!m_Account.Contains(item.CustNo))
     {
         item.Value = "帳號錯誤: " + m_Account;
         return(false);
     }
     return(true);
 }
Beispiel #2
0
        /// <summary>
        /// 取得未平倉資料
        /// </summary>
        /// <param name="data"></param>
        private void GetOpenInterest(RTDItem data)
        {
            if (!_CheckAccount(data))
            {
                return;
            }
            var op = from open in m_OpenInterestList
                     where open.CustNo == data.CustNo && open.ComID == data.ComID
                     select open;

            if (op.Count() == 0)
            {
                data.Value = -1;
                return;
            }
            OpenInterest item = op.First();

            switch (data.Item)
            {
            case "LOTS":
                data.Value = item.Qty * (item.BuySell == BuySell.B ? 1 : -1);
                break;

            case "MARKETPRICE":
                data.Value = item.MP;
                break;

            case "AVGPRICE":
                data.Value = item.AvgP;
                break;

            case "CLOSEPRICE":
                data.Value = item.YstCP;
                break;

            case "PL":
                data.Value = item.ProfitLoss;
                break;

            case "UPDATETIME":
                data.Value = item.UpdateTime;
                break;

            default:
                data.Value = -1;
                break;
            }
        }
Beispiel #3
0
        /// <summary>
        /// 更新單一RTDItem資料
        /// </summary>
        /// <param name="data"></param>
        public void GetRTDItem(RTDItem data)
        {
            switch (data.RTDType)
            {
            case "SUMMARY":
                GetSummary(data);
                break;

            case "OPENINTEREST":
                GetOpenInterest(data);
                break;

            default:
                break;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Excel進行RTD訂閱
        /// </summary>
        /// <param name="TopicID"></param>
        /// <param name="Strings"></param>
        /// <param name="GetNewValues"></param>
        /// <returns></returns>
        public dynamic ConnectData(int TopicID, ref Array Strings, ref bool GetNewValues)
        {
            GetNewValues = true;
            try
            {
                if (m_Subscribes == null)
                {
                    m_Subscribes = new List <RTDItem>();
                }
                RTDItem temp = new RTDItem(Strings);
                m_Getter.GetRTDItem(temp);
                if (temp.Value != null)
                {
                    m_Subscribes.Add(temp);
                }
            }
            catch (Exception)
            {
                return("ERROR IN QUERY.");
            }
            if (!m_tmrTimer.Enabled)
            {
                m_tmrTimer.Start();
            }

            foreach (var item in m_Subscribes)
            {
                if (item.Equals(Strings))
                {
                    if (item.TopicID == -1)
                    {
                        item.TopicID = TopicID;
                    }
                    return(item.Value);
                }
            }
            return("Unrecognized");
        }
Beispiel #5
0
        /// <summary>
        /// 取得彙總資料
        /// </summary>
        /// <param name="data"></param>
        private void GetSummary(RTDItem data)
        {
            if (!_CheckAccount(data))
            {
                return;
            }
            var summary = from order in m_Order.Values
                          where order.OrderType == OrderType.D && order.OrderErr == OrderErr.N
                          group order by
                          new { BrkID = order.BrokerID, CustNo = order.CustNo, ComID = order.ComID } into g
                select new Summary
            {
                BrokerID = g.Key.BrkID,
                CustNo   = g.Key.CustNo,
                ComID    = g.Key.ComID,
                ALot     = g.Where(e => e.BuySell == BuySell.S).Sum(e => e.Qty),
                BLot     = g.Where(e => e.BuySell == BuySell.B).Sum(e => e.Qty),
                AAmt     = g.Where(e => e.BuySell == BuySell.S).Sum(e => e.MatchAmount),
                BAmt     = g.Where(e => e.BuySell == BuySell.B).Sum(e => e.MatchAmount)
            };

            if (summary.Count() == 0)
            {
                data.Value = -1;
                return;
            }
            IEnumerable <Summary> list = summary;

            if (!string.IsNullOrEmpty(data.CustNo) && !string.IsNullOrEmpty(data.ComID))
            {
                list = summary.Where(e => e.CustNo == data.CustNo && e.ComID == data.ComID);
            }
            else if (!string.IsNullOrEmpty(data.CustNo) && string.IsNullOrEmpty(data.ComID))
            {
                list = summary.Where(e => e.CustNo == data.CustNo);
            }
            else if (string.IsNullOrEmpty(data.CustNo) && !string.IsNullOrEmpty(data.ComID))
            {
                list = summary.Where(e => e.ComID == data.ComID);
            }

            switch (data.Item)
            {
            case "BLOT":
                data.Value = list.Sum(e => e.BLot);
                break;

            case "ALOT":
                data.Value = list.Sum(e => e.ALot);
                break;

            case "BAMT":
                data.Value = list.Sum(e => e.BAmt);
                break;

            case "AAMT":
                data.Value = list.Sum(e => e.AAmt);
                break;

            default:
                data.Value = -1;
                break;
            }
        }