Exemple #1
0
        public void OnUpdate(int itemPos, string itemName, IUpdateInfo updateInfo)
        {
            string      key     = updateInfo.GetNewValue("key");
            string      action  = updateInfo.GetNewValue("command");
            FeedMessage feedMsg = new FeedMessage();
            int         indexOfSchemaSpliter = itemName.IndexOf('#');
            string      schemacode           = itemName.Remove(indexOfSchemaSpliter);

            IEnumerable <dsSchema.SchemaInfoRow> rows = m_dsSchema.SchemaInfo.Where(r => r.SchemaCode == schemacode);

            Dictionary <string, string> data = new Dictionary <string, string>();

            foreach (dsSchema.SchemaInfoRow dr in rows)
            {
                string fieldName = dr.FieldName;
                string value     = updateInfo.GetNewValue(dr.FieldName.Trim());

                if (fieldName == "command" || fieldName == "key")
                {
                    continue;
                }
                data.Add(fieldName, value);
            }
            feedMsg.ItemName  = itemName;
            feedMsg.DataItems = data;
            feedMsg.Code      = key.Trim();
            feedMsg.Action    = action.Trim();
            m_ReceivedFeedBCollecion.Add(feedMsg);
        }
Exemple #2
0
 protected override L1LsPriceData LoadUpdate(IUpdateInfo update)
 {
     try
     {
         var l1LsPriceData = new L1LsPriceData
         {
             //If you don't subscribe to the data then you cannot obtain it without an exception
             //MidOpen = StringToNullableDecimal(update.GetNewValue("MID_OPEN")),
             Bid = StringToNullableDecimal(update.GetNewValue("BID")),
             //Change = StringToNullableDecimal(update.GetNewValue("CHANGE")),
             //ChangePct = StringToNullableDecimal(update.GetNewValue("CHANGE_PCT")),
             //High = StringToNullableDecimal(update.GetNewValue("HIGH")),
             //Low = StringToNullableDecimal(update.GetNewValue("LOW")),
             //MarketDelay = StringToNullableInt(update.GetNewValue("MARKET_DELAY")),
             //MarketState = update.GetNewValue("MARKET_STATE"),
             Offer      = StringToNullableDecimal(update.GetNewValue("OFFER")),
             UpdateTime = EpocStringToNullableDateTime(update.GetNewValue("UPDATE_TIME")),
         };
         return(l1LsPriceData);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Exemple #3
0
        public override void OnUpdate(int itemPos, string itemName, IUpdateInfo update)
        {
            try
            {
                var confirms = update.GetNewValue("CONFIRMS");
                var opu      = update.GetNewValue("OPU");
                var wou      = update.GetNewValue("WOU");

                if (!(String.IsNullOrEmpty(confirms)))
                {
                    ProcessConfirmsMessage(confirms);
                }

                if (!(String.IsNullOrEmpty(opu)))
                {
                    ProcessOpuMessage(opu);
                }

                if (!(String.IsNullOrEmpty(wou)))
                {
                    ProcessWouMessage(wou);
                }
            }
            catch (Exception ex)
            {
            }
        }
        public override void OnUpdate(int itemPos, string itemName, IUpdateInfo update)
        {
            try
            {
                var receivers = _tradingService.CandleReceivers.OfType <TicksDataReceiver>().Where(r => itemName.Contains(r.Epic)).ToList();

                if (receivers.Count > 0)
                {
                    var bidStr   = update.GetNewValue("BID");
                    var offerStr = update.GetNewValue("OFR");

                    if (bidStr == null || offerStr == null)
                    {
                        return;
                    }

                    var bid   = Convert.ToDouble(bidStr);
                    var offer = Convert.ToDouble(offerStr);

                    receivers.ForEach(r => r.AddTick(bid, offer));
                }
            }
            catch (Exception ex)
            {
            }
        }
            public override void OnUpdate(int itemPos, string itemName, IUpdateInfo update)
            {
                var sb = new StringBuilder();

                sb.AppendLine("Trade Subscription Update");

                try
                {
                    var confirms = update.GetNewValue("CONFIRMS");
                    var opu      = update.GetNewValue("OPU");
                    var wou      = update.GetNewValue("WOU");

                    if (!(String.IsNullOrEmpty(opu)))
                    {
                        UpdateTs(itemPos, itemName, update, opu, TradeSubscriptionType.Opu);
                    }
                    if (!(String.IsNullOrEmpty(wou)))
                    {
                        UpdateTs(itemPos, itemName, update, wou, TradeSubscriptionType.Wou);
                    }
                    if (!(String.IsNullOrEmpty(confirms)))
                    {
                        UpdateTs(itemPos, itemName, update, confirms, TradeSubscriptionType.Confirm);
                    }
                }
                catch (Exception ex)
                {
                    _applicationViewModel.ApplicationDebugData += "Exception thrown in TradeSubscription Lightstreamer update" + ex.Message;
                }
            }
 public void OnItemUpdate(int itemPos, string itemName, IUpdateInfo update)
 {
     if (textMeshFound && suscribedItemName.Equals(itemName))
     {
         textMeshStr = update.GetNewValue(1) + ": " + update.GetNewValue(2);             //update.ToString();
     }
     Debug.Log("OnItemUpdate: " + itemName + ", update: " + update);
 }
Exemple #7
0
 public void OnUpdate(int itemPos, string itemName, IUpdateInfo update)
 {
     Console.WriteLine(NotifyUpdate(update) +
                       " for " + itemPos + ":" +
                       " key = " + update.GetNewValue(1) +
                       " command = " + update.GetNewValue(2) +
                       NotifyValue(update, 3, "qty"));
 }
    new public void RTUpdates(IUpdateInfo update)
    {
        if (!update.ItemName.Equals(this.ItemName))
        {
            return;
        }

        if (update.IsValueChanged("message"))
        {
            Debug.Log("Message:" + update.GetNewValue("message"));

            GetComponent <TextMesh>().text = update.GetNewValue("message");
        }
    }
Exemple #9
0
        public void OnItemUpdate(int phase, int itemPos, string itemName, IUpdateInfo update)
        {
            if (!App.checkPhase(phase))
            {
                return;
            }
            Dictionary <int, UpdateCell> TextMap;

            if (RowMap.TryGetValue(itemPos, out TextMap))
            {
                for (int i = 0; i < App.fields.Length; i++)
                {
                    string field = App.fields[i];
                    if (update.IsValueChanged(field) || update.Snapshot)
                    {
                        UpdateCell cell;
                        if (TextMap.TryGetValue(i, out cell))
                        {
                            cell.SetText(update.GetNewValue(field));
                            if (field.Equals("last_price"))
                            {
                                cell.Animate(update, field, TextMap);
                            }
                        }
                    }
                }
            }

            Debug.WriteLine("OnItemUpdate: " + itemName + ", " + update + ", pos: " + itemPos);
        }
Exemple #10
0
            public void Animate(IUpdateInfo update, string field, Dictionary <int, UpdateCell> TextMap)
            {
                string oldval = update.GetOldValue(field);
                string newval = update.GetNewValue(field);
                int    action = 0;

                try
                {
                    if (Convert.ToDouble(oldval) > Convert.ToDouble(newval))
                    {
                        action = -1;
                    }
                    else
                    {
                        action = 1;
                    }
                } catch (FormatException) {
                    // ignore
                }
                foreach (UpdateCell cell in TextMap.Values)
                {
                    if (action > 0)
                    {
                        cell.AnimateUp();
                    }
                    else if (action < 0)
                    {
                        cell.AnimateDown();
                    }
                    else
                    {
                        cell.AnimateSame();
                    }
                }
            }
Exemple #11
0
 public void Animate(IUpdateInfo update, string field, Dictionary<int, UpdateCell> TextMap)
 {
     string oldval = update.GetOldValue(field);
     string newval = update.GetNewValue(field);
     int action = 0;
     try
     {
         if (Convert.ToDouble(oldval) > Convert.ToDouble(newval))
             action = -1;
         else
             action = 1;
     }
     catch (FormatException)
     {
         // ignore
     }
     foreach (UpdateCell cell in TextMap.Values)
     {
         if (action > 0)
             cell.AnimateUp();
         else if (action < 0)
             cell.AnimateDown();
         else
             cell.AnimateSame();
     }
 }
Exemple #12
0
        protected override TradeData LoadUpdate(IUpdateInfo update)
        {
            try
            {
                TradeData tradeData = new TradeData();

                var confirms = update.GetNewValue("CONFIRMS");
                var opu      = update.GetNewValue("OPU");
                var wou      = update.GetNewValue("WOU");

                if (!(String.IsNullOrEmpty(opu)))
                {
                    System.Console.WriteLine("Update type is opu");
                    tradeData.Type = TradeSubscriptionType.Opu;

                    tradeData.OPUResponse = JsonConvert.DeserializeObject <TradeDataOPUResponse>(opu);

                    return(tradeData);
                }
                if (!(String.IsNullOrEmpty(wou)))
                {
                    System.Console.WriteLine("Update type is wou");

                    tradeData.Type = TradeSubscriptionType.Wou;

                    tradeData.WOUResponse = JsonConvert.DeserializeObject <TradeDataWOUResponse>(wou);

                    return(tradeData);
                }
                if (!(String.IsNullOrEmpty(confirms)))
                {
                    System.Console.WriteLine("Update type is confirms");

                    tradeData.Type = TradeSubscriptionType.Confirm;

                    tradeData.ConfirmResponse = JsonConvert.DeserializeObject <TradeDataConfirmResponse>(confirms);

                    return(tradeData);
                }

                return(null);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
 protected override StreamingAccountData LoadUpdate(IUpdateInfo update)
 {
     try
     {
         var streamingAccountData = new StreamingAccountData
         {
             ProfitAndLoss = StringToNullableDecimal(update.GetNewValue("PNL")),
             Deposit       = StringToNullableDecimal(update.GetNewValue("DEPOSIT")),
             UsedMargin    = StringToNullableDecimal(update.GetNewValue("USED_MARGIN")),
             AmountDue     = StringToNullableDecimal(update.GetNewValue("AMOUNT_DUE")),
             AvailableCash = StringToNullableDecimal(update.GetNewValue("AVAILABLE_CASH"))
         };
         return(streamingAccountData);
     }
     catch (Exception)
     {
         return(null);
     }
 }
        public override void OnUpdate(int itemPos, string itemName, IUpdateInfo update)
        {
            try
            {
                var receiver = _tradingService.CandleReceivers.OfType <CandleDataReceiver>().Skip(itemPos - 1).FirstOrDefault();

                if (receiver != null)
                {
                    var end = update.GetNewValue("CONS_END");

                    var      timeStr = update.GetNewValue("UTM");
                    DateTime time    = DateTime.Now;

                    if (timeStr != null)
                    {
                        time = FromUnixTime(Convert.ToInt64(timeStr) / 1000).ToLocalTime();
                    }

                    var bidStr   = update.GetNewValue("BID_CLOSE");
                    var offerStr = update.GetNewValue("OFR_CLOSE");

                    if (string.IsNullOrEmpty(bidStr) || string.IsNullOrEmpty(offerStr))
                    {
                        return;
                    }

                    var close = (Convert.ToDouble(bidStr) + Convert.ToDouble(offerStr)) / 2;

                    var open = (Convert.ToDouble(update.GetNewValue("BID_OPEN")) +
                                Convert.ToDouble(update.GetNewValue("OFR_OPEN"))) / 2;
                    var low = (Convert.ToDouble(update.GetNewValue("BID_LOW")) +
                               Convert.ToDouble(update.GetNewValue("OFR_LOW"))) / 2;
                    var high = (Convert.ToDouble(update.GetNewValue("BID_HIGH")) +
                                Convert.ToDouble(update.GetNewValue("OFR_HIGH"))) / 2;

                    receiver.CandleUpdate(time, open, close, high, low, end == "1");
                }
            }
            catch (Exception ex)
            {
            }
        }
 private string NotifyValue(IUpdateInfo update, string fldName)
 {
     string newValue = update.GetNewValue(fldName);
     string notify = " " + fldName + " = " + (newValue != null ? newValue : "null");
     if (update.IsValueChanged(fldName))
     {
         string oldValue = update.GetOldValue(fldName);
         notify += " (was " + (oldValue != null ? oldValue : "null") + ")";
     }
     return notify;
 }
Exemple #16
0
    new public void RTUpdates(IUpdateInfo update)
    {
        if (!update.ItemName.Equals(this.ItemName))
        {
            return;
        }

        if (update.ItemName.StartsWith("item"))
        {
            if (update.IsValueChanged(2))
            {
                float ftmp = 1;
                float.TryParse(update.GetNewValue(2), out ftmp);

                int iValue  = Mathf.FloorToInt(ftmp);
                int iValue2 = Mathf.FloorToInt(ftmp / 2.0F);

                if (this.cc == 0)
                {
                    this.redC  = (this.redC + iValue) % 255;
                    this.blueC = (this.blueC + iValue2) % 255;
                }
                else
                {
                    this.greenC = (this.greenC + iValue) % 255;
                    this.blueC  = (this.blueC + iValue2) % 255;
                }
            }
            if (update.IsValueChanged(4))
            {
                float ftmp = 1;
                float.TryParse(update.GetNewValue(4), out ftmp);

                Debug.Log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: " + ftmp);

                this.scale = 3.0F + (3.0F * ftmp / 5000.0F);

                Debug.Log("New scale: " + this.scale);
            }
        }
    }
Exemple #17
0
        private string NotifyValue(IUpdateInfo update, string fldName)
        {
            string newValue = update.GetNewValue(fldName);
            string notify   = " " + fldName + " = " + (newValue != null ? newValue : "null");

            if (update.IsValueChanged(fldName))
            {
                string oldValue = update.GetOldValue(fldName);
                notify += " (was " + (oldValue != null ? oldValue : "null") + ")";
            }
            return(notify);
        }
Exemple #18
0
 /// <summary>
 /// It seems some streams have a 'spin-up' process that can return an all null update
 /// until the data starts streaming. We were not catching this and null updates were
 /// sometimes throwing exceptions that were logged and then swallowed by LS. I think
 /// a better way is to determine if the update is emtpy (null) and simply not fire if so.
 ///
 /// Follows is a very simple check
 /// </summary>
 /// <param name="update"></param>
 /// <returns></returns>
 private static bool IsUpdateNull(IUpdateInfo update)
 {
     for (int i = 1; i < update.NumFields + 1; i++)
     {
         object value = update.IsValueChanged(i) ? update.GetNewValue(i) : update.GetOldValue(i);
         if (value != null)
         {
             return(false);
         }
     }
     return(true);
 }
Exemple #19
0
        /// <summary>
        /// SimpleTableInfo
        /// </summary>
        /// <param name="itemPos"></param>
        /// <param name="itemName"></param>
        /// <param name="updateInfo"></param>
        public void _OnUpdate(int itemPos, string itemName, IUpdateInfo updateInfo)
        {
            itemName = updateInfo.GetNewValue(6);  // will be modified to remove hard coded value.
            FeedMessage feedMsg = new FeedMessage();
            int         indexOfSchemaSpliter = itemName.IndexOf('#');
            string      schemacode           = itemName.Remove(indexOfSchemaSpliter);

            IEnumerable <dsSchema.SchemaInfoRow> rows = m_dsSchema.SchemaInfo.Where(r => r.SchemaCode == schemacode);

            Dictionary <string, string> data = new Dictionary <string, string>();

            foreach (dsSchema.SchemaInfoRow dr in rows)
            {
                string fieldName = dr.FieldName;
                string value     = updateInfo.GetNewValue(dr.FieldIndex);
                data.Add(fieldName, value);
            }
            feedMsg.ItemName  = itemName;
            feedMsg.DataItems = data;
            m_ReceivedFeedBCollecion.Add(feedMsg);
        }
        public void OnUpdate(int itemPos, string itemName, IUpdateInfo updateInfo)
        {
            //  string itemsubCode =   updateInfo.GetNewValue(1);

            Console.WriteLine("===============================================================");
            // Console.WriteLine("Item of Code : {0} received at : {1}", itemsubCode, DateTime.Now);
            Console.WriteLine("Value = {0} at inedex 1 received", updateInfo.GetNewValue(1));
            Console.WriteLine("Value = {0} at inedex 2 received", updateInfo.GetNewValue(2));
            Console.WriteLine("Value = {0} at inedex 3 received", updateInfo.GetNewValue(3));
            Console.WriteLine("Value = {0} at inedex 4 received", updateInfo.GetNewValue(4));
            Console.WriteLine("Value = {0} at inedex 5 received", updateInfo.GetNewValue(5));
            Console.WriteLine("***************************************************************");

            UpdateMessage msg = new UpdateMessage();

            //  msg.MessagePrefix = itemsubCode.Substring(0,2);
            msg.ItemName = itemName;//itemsubCode;
            // msg.Code = itemsubCode.Substring(2, itemsubCode.Length - 2);
            msg.UpdateInfo = updateInfo;
            m_ReceivedFeedBCollecion.Add(msg);
        }
        public StreamingAccountData StreamingAccountDataUpdates(int itemPos, string itemName, IUpdateInfo update)
        {
            var streamingAccountData = new StreamingAccountData();

            try
            {
                var pnl           = update.GetNewValue("PNL");
                var deposit       = update.GetNewValue("DEPOSIT");
                var usedMargin    = update.GetNewValue("USED_MARGIN");
                var amountDue     = update.GetNewValue("AMOUNT_DUE");
                var availableCash = update.GetNewValue("AVAILABLE_CASH");

                if (!String.IsNullOrEmpty(pnl))
                {
                    streamingAccountData.ProfitAndLoss = Convert.ToDecimal(pnl);
                }
                if (!String.IsNullOrEmpty(deposit))
                {
                    streamingAccountData.Deposit = Convert.ToDecimal(deposit);
                }
                if (!String.IsNullOrEmpty(usedMargin))
                {
                    streamingAccountData.UsedMargin = Convert.ToDecimal(usedMargin);
                }
                if (!String.IsNullOrEmpty(amountDue))
                {
                    streamingAccountData.AmountDue = Convert.ToDecimal(amountDue);
                }
                if (!String.IsNullOrEmpty(availableCash))
                {
                    streamingAccountData.AmountDue = Convert.ToDecimal(availableCash);
                }
            }
            catch (Exception)
            {
            }
            return(streamingAccountData);
        }
        private static string GetCurrentValue(IUpdateInfo updateInfo, int pos)
        {
            string value;

            if (updateInfo.IsValueChanged(pos))
            {
                value = updateInfo.GetNewValue(pos);
            }
            else
            {
                value = updateInfo.GetOldValue(pos);
            }
            return(value);
        }
Exemple #23
0
        public override void OnUpdate(int itemPos, string itemName, IUpdateInfo update)
        {
            try
            {
                if (_tickReceiver != null)
                {
                    var bidStr   = update.GetNewValue("BID");
                    var offerStr = update.GetNewValue("OFR");

                    if (bidStr == null || offerStr == null)
                    {
                        return;
                    }

                    var bid   = Convert.ToDouble(bidStr);
                    var offer = Convert.ToDouble(offerStr);

                    _tickReceiver.AddTick(bid, offer);
                }
            }
            catch (Exception ex)
            {
            }
        }
 protected override L1LsPriceData LoadUpdate(IUpdateInfo update)
 {
     try
     {
         var lsL1PriceData = new L1LsPriceData
         {
             MidOpen     = StringToNullableDecimal(update.GetNewValue("MID_OPEN")),
             High        = StringToNullableDecimal(update.GetNewValue("HIGH")),
             Low         = StringToNullableDecimal(update.GetNewValue("LOW")),
             Change      = StringToNullableDecimal(update.GetNewValue("CHANGE")),
             ChangePct   = StringToNullableDecimal(update.GetNewValue("CHANGE_PCT")),
             UpdateTime  = update.GetNewValue("UPDATE_TIME"),
             MarketDelay = StringToNullableInt(update.GetNewValue("MARKET_DELAY")),
             MarketState = update.GetNewValue("MARKET_STATE"),
             Bid         = StringToNullableDecimal(update.GetNewValue("BID")),
             Offer       = StringToNullableDecimal(update.GetNewValue("OFFER"))
         };
         return(lsL1PriceData);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Exemple #25
0
        private static string GetCurrentValue(IUpdateInfo updateInfo, int pos)
        {
            string result;

            if (updateInfo.IsValueChanged(pos))
            {
                result = updateInfo.GetNewValue(pos);
            }
            else
            {
                result = updateInfo.GetOldValue(pos);
            }

            return(result);
        }
        public string L1PriceUpdates(int itemPos, string itemName, IUpdateInfo update)
        {
            var sb = new StringBuilder();

            sb.AppendLine("Item Position: " + itemPos);
            sb.AppendLine("Item Name: " + itemName);

            try
            {
                var midOpen     = update.GetNewValue("MID_OPEN");
                var high        = update.GetNewValue("HIGH");
                var low         = update.GetNewValue("LOW");
                var change      = update.GetNewValue("CHANGE");
                var changePct   = update.GetNewValue("CHANGE_PCT");
                var updateTime  = update.GetNewValue("UPDATE_TIME");
                var marketDelay = update.GetNewValue("MARKET_DELAY");
                var marketState = update.GetNewValue("MARKET_STATE");
                var bid         = update.GetNewValue("BID");
                var offer       = update.GetNewValue("OFFER");

                if (!String.IsNullOrEmpty(midOpen))
                {
                    sb.AppendLine("mid open: " + midOpen);
                }
                if (!String.IsNullOrEmpty(high))
                {
                    sb.AppendLine("high: " + high);
                }
                if (!String.IsNullOrEmpty(low))
                {
                    sb.AppendLine("low: " + low);
                }
                if (!String.IsNullOrEmpty(change))
                {
                    sb.AppendLine("change: " + change);
                }
                if (!String.IsNullOrEmpty(changePct))
                {
                    sb.AppendLine("change percent: " + changePct);
                }
                if (!String.IsNullOrEmpty(updateTime))
                {
                    sb.AppendLine("update time: " + updateTime);
                }
                if (!String.IsNullOrEmpty(marketDelay))
                {
                    sb.AppendLine("market delay: " + marketDelay);
                }
                if (!String.IsNullOrEmpty(marketState))
                {
                    sb.AppendLine("market state: " + marketState);
                }
                if (!String.IsNullOrEmpty(bid))
                {
                    sb.AppendLine("bid: " + bid);
                }
                if (!String.IsNullOrEmpty(offer))
                {
                    sb.AppendLine("offer: " + offer);
                }
            }
            catch (Exception ex)
            {
                sb.AppendLine("Exception in L1 Prices");
                sb.AppendLine(ex.Message);
            }
            return(sb.ToString());
        }
Exemple #27
0
        public L1LsPriceData L1LsPriceUpdateData (int itemPos, string itemName, IUpdateInfo update)
        {
            var lsL1PriceData = new L1LsPriceData();
            try
            {
                var midOpen = update.GetNewValue("MID_OPEN");
                var high = update.GetNewValue("HIGH");
                var low = update.GetNewValue("LOW");
                var change = update.GetNewValue("CHANGE");
                var changePct = update.GetNewValue("CHANGE_PCT");
                var updateTime = update.GetNewValue("UPDATE_TIME");
                var marketDelay = update.GetNewValue("MARKET_DELAY");
                var marketState = update.GetNewValue("MARKET_STATE");
                var bid = update.GetNewValue("BID");
                var offer = update.GetNewValue("OFFER");

                if (!String.IsNullOrEmpty(midOpen))               
                {
                    lsL1PriceData.MidOpen = Convert.ToDecimal(midOpen);
                }
                if (!String.IsNullOrEmpty(high))        
                {
                    lsL1PriceData.High = Convert.ToDecimal(high);
                }
                if (!String.IsNullOrEmpty(low))  
                {
                    lsL1PriceData.Low = Convert.ToDecimal(low);
                }
                if (!String.IsNullOrEmpty(change))
                {
                    lsL1PriceData.Change = Convert.ToDecimal(change);
                }
                if (!String.IsNullOrEmpty(changePct))
                {
                    lsL1PriceData.ChangePct = Convert.ToDecimal(changePct);
                }
                if (!String.IsNullOrEmpty(updateTime))               
                {
                    lsL1PriceData.UpdateTime = updateTime;
                }
                if (!String.IsNullOrEmpty(marketDelay))
                {
                    lsL1PriceData.MarketDelay = Convert.ToInt32(marketDelay);
                }
                if (!String.IsNullOrEmpty(marketState))
                {              
                    lsL1PriceData.MarketState = marketState;
                }
                if (!String.IsNullOrEmpty(bid))
                {
                    lsL1PriceData.Bid = Convert.ToDecimal(bid);
                }
                if (!String.IsNullOrEmpty(offer))
                {
                    lsL1PriceData.Offer = Convert.ToDecimal(offer);
                }
            }
            catch (Exception)
            {                
            }
            return lsL1PriceData;
        }
        public L1LsPriceData L1LsPriceUpdateData(int itemPos, string itemName, IUpdateInfo update)
        {
            var lsL1PriceData = new L1LsPriceData();

            try
            {
                var midOpen     = update.GetNewValue("MID_OPEN");
                var high        = update.GetNewValue("HIGH");
                var low         = update.GetNewValue("LOW");
                var change      = update.GetNewValue("CHANGE");
                var changePct   = update.GetNewValue("CHANGE_PCT");
                var updateTime  = update.GetNewValue("UPDATE_TIME");
                var marketDelay = update.GetNewValue("MARKET_DELAY");
                var marketState = update.GetNewValue("MARKET_STATE");
                var bid         = update.GetNewValue("BID");
                var offer       = update.GetNewValue("OFFER");

                if (!String.IsNullOrEmpty(midOpen))
                {
                    lsL1PriceData.MidOpen = Convert.ToDecimal(midOpen);
                }
                if (!String.IsNullOrEmpty(high))
                {
                    lsL1PriceData.High = Convert.ToDecimal(high);
                }
                if (!String.IsNullOrEmpty(low))
                {
                    lsL1PriceData.Low = Convert.ToDecimal(low);
                }
                if (!String.IsNullOrEmpty(change))
                {
                    lsL1PriceData.Change = Convert.ToDecimal(change);
                }
                if (!String.IsNullOrEmpty(changePct))
                {
                    lsL1PriceData.ChangePct = Convert.ToDecimal(changePct);
                }
                if (!String.IsNullOrEmpty(updateTime))
                {
                    lsL1PriceData.UpdateTime = updateTime;
                }
                if (!String.IsNullOrEmpty(marketDelay))
                {
                    lsL1PriceData.MarketDelay = Convert.ToInt32(marketDelay);
                }
                if (!String.IsNullOrEmpty(marketState))
                {
                    lsL1PriceData.MarketState = marketState;
                }
                if (!String.IsNullOrEmpty(bid))
                {
                    lsL1PriceData.Bid = Convert.ToDecimal(bid);
                }
                if (!String.IsNullOrEmpty(offer))
                {
                    lsL1PriceData.Offer = Convert.ToDecimal(offer);
                }
            }
            catch (Exception)
            {
            }
            return(lsL1PriceData);
        }
Exemple #29
0
        public string L1PriceUpdates(int itemPos, string itemName, IUpdateInfo update)
        {
            var sb = new StringBuilder();
            sb.AppendLine("Item Position: " + itemPos);
            sb.AppendLine("Item Name: " + itemName);

            try
            {
                var midOpen = update.GetNewValue("MID_OPEN");
                var high = update.GetNewValue("HIGH");
                var low = update.GetNewValue("LOW");
                var change = update.GetNewValue("CHANGE");
                var changePct = update.GetNewValue("CHANGE_PCT");
                var updateTime = update.GetNewValue("UPDATE_TIME");
                var marketDelay = update.GetNewValue("MARKET_DELAY");
                var marketState = update.GetNewValue("MARKET_STATE");
                var bid = update.GetNewValue("BID");
                var offer = update.GetNewValue("OFFER");

                if (!String.IsNullOrEmpty(midOpen))
                {
                    sb.AppendLine("mid open: " + midOpen);
                }
                if (!String.IsNullOrEmpty(high))
                {
                    sb.AppendLine("high: " + high);
                }
                if (!String.IsNullOrEmpty(low))
                {
                    sb.AppendLine("low: " + low);
                }
                if (!String.IsNullOrEmpty(change))
                {
                    sb.AppendLine("change: " + change);
                }
                if (!String.IsNullOrEmpty(changePct))
                {
                    sb.AppendLine("change percent: " + changePct);
                }
                if (!String.IsNullOrEmpty(updateTime))
                {
                    sb.AppendLine("update time: " + updateTime);
                }
                if (!String.IsNullOrEmpty(marketDelay))
                {
                    sb.AppendLine("market delay: " + marketDelay);
                }
                if (!String.IsNullOrEmpty(marketState))
                {
                    sb.AppendLine("market state: " + marketState);
                }
                if (!String.IsNullOrEmpty(bid))
                {
                    sb.AppendLine("bid: " + bid);
                }
                if (!String.IsNullOrEmpty(offer))
                {
                    sb.AppendLine("offer: " + offer);
                }
            }
            catch (Exception ex)
            {
                sb.AppendLine("Exception in L1 Prices");
                sb.AppendLine(ex.Message);
            }
            return sb.ToString();
        }
Exemple #30
0
        private void OnLightstreamerUpdate(int item, IUpdateInfo values)
        {
            dataGridview.SuspendLayout();

            if (this.isDirty)
            {
                this.isDirty = false;
                CleanGrid();
            }

            DataGridViewRow row = dataGridview.Rows[item - 1];

            ArrayList cells = new ArrayList();
            int len = values.NumFields;
            for (int i = 0; i < len; i++) {
                if (values.IsValueChanged(i + 1)) {
                    string val = values.GetNewValue(i + 1);
                    DataGridViewCell cell = row.Cells[i];

                    switch (i) {
                        case 1: // last_price          
                        case 5: // bid
                        case 6: // ask
                        case 8: // min
                        case 9: // max
                        case 10: // ref_price
                        case 11: // open_price
                            double dVal = Double.Parse(val, CultureInfo.GetCultureInfo("en-US").NumberFormat);
                            cell.Value = dVal;
                            break;

                        case 3: // pct_change
                            double dVal2 = Double.Parse(val, CultureInfo.GetCultureInfo("en-US").NumberFormat);
                            cell.Value = dVal2;
                            cell.Style.ForeColor = ((dVal2 < 0.0) ? Color.Red : Color.Green);
                            break;

                        case 4: // bid_quantity
                        case 7: // ask_quantity
                            int lVal = Int32.Parse(val);
                            cell.Value = lVal;
                            break;

                        case 2: // time
                            DateTime dtVal = DateTime.Parse(val);
                            cell.Value = dtVal;
                            break;

                        default: // stock_name, ...
                            cell.Value = val;
                            break;
                    }

                    if (blinkEnabled) {
                        cell.Style.BackColor = blinkOnColor;
                        cells.Add(cell);
                    }
                }
            }

            dataGridview.ResumeLayout();

            if (blinkEnabled) {
                long now = DateTime.Now.Ticks;
                ScheduleBlinkOff(cells, now);
            }
        }
        public void OnUpdate(int itemPos, string itemName, IUpdateInfo update)
        {
            Stock stock = gridModel[itemPos - 1];
            stock.StockName = update.GetNewValue("stock_name");
            stock.LastPrice = update.GetNewValue("last_price");
            stock.Time = update.GetNewValue("time");
            stock.PctChange = update.GetNewValue("pct_change");
            stock.BidQuantity = update.GetNewValue("bid_quantity");
            stock.Bid = update.GetNewValue("bid");
            stock.Ask = update.GetNewValue("ask");
            stock.AskQuantity = update.GetNewValue("ask_quantity");
            stock.Min = update.GetNewValue("min");
            stock.Max = update.GetNewValue("max");
            stock.RefPrice = update.GetNewValue("ref_price");
            stock.OpenPrice = update.GetNewValue("open_price");

            this.page.setData(this.phase, stock);
        }
Exemple #32
0
        private void OnLightstreamerUpdate(int item, IUpdateInfo values)
        {
            dataGridview.SuspendLayout();

            if (this.isDirty)
            {
                this.isDirty = false;
                CleanGrid();
            }

            DataGridViewRow row = dataGridview.Rows[item - 1];

            ArrayList cells = new ArrayList();
            int       len   = values.NumFields;

            for (int i = 0; i < len; i++)
            {
                if (values.IsValueChanged(i + 1))
                {
                    string           val  = values.GetNewValue(i + 1);
                    DataGridViewCell cell = row.Cells[i];

                    switch (i)
                    {
                    case 1:     // last_price
                    case 5:     // bid
                    case 6:     // ask
                    case 8:     // min
                    case 9:     // max
                    case 10:    // ref_price
                    case 11:    // open_price
                        double dVal = Double.Parse(val, CultureInfo.GetCultureInfo("en-US").NumberFormat);
                        cell.Value = dVal;
                        break;

                    case 3:     // pct_change
                        double dVal2 = Double.Parse(val, CultureInfo.GetCultureInfo("en-US").NumberFormat);
                        cell.Value           = dVal2;
                        cell.Style.ForeColor = ((dVal2 < 0.0) ? Color.Red : Color.Green);
                        break;

                    case 4:     // bid_quantity
                    case 7:     // ask_quantity
                        int lVal = Int32.Parse(val);
                        cell.Value = lVal;
                        break;

                    case 2:     // time
                        DateTime dtVal = DateTime.Parse(val);
                        cell.Value = dtVal;
                        break;

                    default:     // stock_name, ...
                        cell.Value = val;
                        break;
                    }

                    if (blinkEnabled)
                    {
                        cell.Style.BackColor = blinkOnColor;
                        cells.Add(cell);
                    }
                }
            }

            dataGridview.ResumeLayout();

            if (blinkEnabled)
            {
                long now = DateTime.Now.Ticks;
                ScheduleBlinkOff(cells, now);
            }
        }
Exemple #33
0
        public void OnItemUpdate(int phase, int itemPos, string itemName, IUpdateInfo update)
        {
            if (!App.checkPhase(phase))
            {
                return;
            }
            Dictionary<int, UpdateCell> TextMap;
            if (RowMap.TryGetValue(itemPos, out TextMap))
            {

                for (int i = 0; i < App.fields.Length; i++)
                {
                    string field = App.fields[i];
                    if (update.IsValueChanged(field) || update.Snapshot)
                    {
                        UpdateCell cell;
                        if (TextMap.TryGetValue(i, out cell))
                        {
                            cell.SetText(update.GetNewValue(field));
                            if (field.Equals("last_price"))
                                cell.Animate(update, field, TextMap);
                        }
                    }
                }

            }

            Debug.WriteLine("OnItemUpdate: " + itemName + ", " + update + ", pos: " + itemPos);
        }
 protected override ChartTickData LoadUpdate(IUpdateInfo update)
 {
     try
     {
         var updateData = new ChartTickData
         {
             Bid                     = StringToNullableDecimal(update.GetNewValue("BID")),
             Offer                   = StringToNullableDecimal(update.GetNewValue("OFR")),
             LastTradedPrice         = StringToNullableDecimal(update.GetNewValue("LTP")),
             LastTradedVolume        = StringToNullableDecimal(update.GetNewValue("LTV")),
             IncrimetalTradingVolume = StringToNullableDecimal(update.GetNewValue("TTV")),
             UpdateTime              = EpocStringToNullableDateTime(update.GetNewValue("UTM")),
             DayMidOpenPrice         = StringToNullableDecimal(update.GetNewValue("DAY_OPEN_MID")),
             DayChange               = StringToNullableDecimal(update.GetNewValue("DAY_NET_CHG_MID")),
             DayChangePct            = StringToNullableDecimal(update.GetNewValue("DAY_PERC_CHG_MID")),
             DayHigh                 = StringToNullableDecimal(update.GetNewValue("DAY_HIGH")),
             DayLow                  = StringToNullableDecimal(update.GetNewValue("DAY_LOW"))
         };
         return(updateData);
     }
     catch (Exception)
     {
         return(null);
     }
 }
 public override void OnUpdate(int itemPos, string itemName, IUpdateInfo update)
 {                             
     _form.AppendStreamingDataMessage("account balance update - P/L : " + update.GetNewValue("PNL"));
     _form.AppendStreamingDataMessage("account balance update - DEPOSIT : " + update.GetNewValue("DEPOSIT"));
     _form.AppendStreamingDataMessage("account balance update - AVAILABLE_CASH : " + update.GetNewValue("AVAILABLE_CASH"));
 }
 public override void OnUpdate(int itemPos, string itemName, IUpdateInfo update) 
 {     
     _form.AppendStreamingDataMessage("trade confirm: " + update.GetNewValue("CONFIRMS"));
     _form.AppendStreamingDataMessage("open position updates: " + update.GetNewValue("OPU"));
     _form.AppendStreamingDataMessage("working order updates: " + update.GetNewValue("WOU"));   
 }
 protected override ChartCandelData LoadUpdate(IUpdateInfo update)
 {
     try
     {
         var updateData = new ChartCandelData
         {
             Bid = new HlocData {
                 High = StringToNullableDecimal(update.GetNewValue("BID_HIGH")), Low = StringToNullableDecimal(update.GetNewValue("BID_LOW")), Open = StringToNullableDecimal(update.GetNewValue("BID_OPEN")), Close = StringToNullableDecimal(update.GetNewValue("BID_CLOSE"))
             },
             Offer = new HlocData {
                 High = StringToNullableDecimal(update.GetNewValue("OFR_HIGH")), Low = StringToNullableDecimal(update.GetNewValue("OFR_LOW")), Open = StringToNullableDecimal(update.GetNewValue("OFR_OPEN")), Close = StringToNullableDecimal(update.GetNewValue("OFR_CLOSE"))
             },
             LastTradedPrice = new HlocData {
                 High = StringToNullableDecimal(update.GetNewValue("LTP_HIGH")), Low = StringToNullableDecimal(update.GetNewValue("LTP_LOW")), Open = StringToNullableDecimal(update.GetNewValue("LTP_OPEN")), Close = StringToNullableDecimal(update.GetNewValue("LTP_CLOSE"))
             },
             LastTradedVolume        = StringToNullableDecimal(update.GetNewValue("LTV")),
             IncrimetalTradingVolume = StringToNullableDecimal(update.GetNewValue("TTV")),
             UpdateTime      = EpocStringToNullableDateTime(update.GetNewValue("UTM")),
             DayMidOpenPrice = StringToNullableDecimal(update.GetNewValue("DAY_OPEN_MID")),
             DayChange       = StringToNullableDecimal(update.GetNewValue("DAY_NET_CHG_MID")),
             DayChangePct    = StringToNullableDecimal(update.GetNewValue("DAY_PERC_CHG_MID")),
             DayHigh         = StringToNullableDecimal(update.GetNewValue("DAY_HIGH")),
             DayLow          = StringToNullableDecimal(update.GetNewValue("DAY_LOW")),
             TickCount       = StringToNullableInt(update.GetNewValue("CONS_TICK_COUNT"))
         };
         var conEnd = StringToNullableInt(update.GetNewValue("CONS_END"));
         updateData.EndOfConsolidation = conEnd.HasValue ? conEnd > 0 : (bool?)null;
         return(updateData);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Exemple #38
0
        public void OnUpdate(int itemPos, string itemName, IUpdateInfo update)
        {
            Stock stock = gridModel[itemPos - 1];

            stock.StockName   = update.GetNewValue("stock_name");
            stock.LastPrice   = update.GetNewValue("last_price");
            stock.Time        = update.GetNewValue("time");
            stock.PctChange   = update.GetNewValue("pct_change");
            stock.BidQuantity = update.GetNewValue("bid_quantity");
            stock.Bid         = update.GetNewValue("bid");
            stock.Ask         = update.GetNewValue("ask");
            stock.AskQuantity = update.GetNewValue("ask_quantity");
            stock.Min         = update.GetNewValue("min");
            stock.Max         = update.GetNewValue("max");
            stock.RefPrice    = update.GetNewValue("ref_price");
            stock.OpenPrice   = update.GetNewValue("open_price");

            this.page.setData(this.phase, stock);
        }
            public override void OnUpdate(int itemPos, string itemName, IUpdateInfo update)
            {
                var sb = new StringBuilder();
                sb.AppendLine("Trade Subscription Update");
               
                try
                {
                    var confirms = update.GetNewValue("CONFIRMS");
                    var opu = update.GetNewValue("OPU");
                    var wou = update.GetNewValue("WOU");                   

                    if (!(String.IsNullOrEmpty(opu)))
                    {                                       
                        UpdateTs(itemPos, itemName, update, opu, TradeSubscriptionType.Opu);                       
                    }
                    if (!(String.IsNullOrEmpty(wou)))
                    {                                    
                        UpdateTs(itemPos, itemName, update, wou, TradeSubscriptionType.Wou);                       
                    }
                    if (!(String.IsNullOrEmpty(confirms)))
                    {                        
                        UpdateTs(itemPos, itemName, update, confirms, TradeSubscriptionType.Confirm);
                    }

                }
                catch (Exception ex)
                {
                    _applicationViewModel.ApplicationDebugData += "Exception thrown in TradeSubscription Lightstreamer update" + ex.Message;                                  
                }                       
            }            
        public void OnItemUpdate(int itemPos, string itemName, IUpdateInfo update)
        {
            List <string> item_fields = null;

            flowForm.AppendLightstreamerLog("OnItemUpdate, pos: " + itemPos + ", name: " +
                                            itemName + ", update:" + update);
            flowForm.TickItemsCountLabel();

            if (!feedingToggle)
            {
                flowForm.AppendLightstreamerLog("OnItemUpdate, not feeding Excel.");
                return;
            }

            itemCache[itemName] = update;


            if (subsDone.TryGetValue(itemName, out item_fields))
            {
                bool updatesExist = false;
                foreach (string field in item_fields)
                {
                    try
                    {
                        if (update.IsValueChanged(field))
                        {
                            if (update.GetNewValue(field) != null)
                            {
                                // push to update queue
                                if (updateQueue.Count() < updateQueueMaxLength)
                                {
                                    int topicId;
                                    if (reverseTopicIdMap.TryGetValue(itemName + "@" + field, out topicId))
                                    {
                                        updatesExist = true;
                                        updateQueue.Enqueue(new RtdUpdateQueueItem(topicId, field, update));
                                        if (field.Equals("time"))
                                        {
                                            int topicId_Last;
                                            if (reverseTopicIdMap.TryGetValue("LAST", out topicId_Last))
                                            {
                                                updateQueue.Enqueue(new RtdUpdateQueueItem(topicId_Last, "", update.GetNewValue(field)));
                                            }
                                        }
                                        if (field.Equals("last_price"))
                                        {
                                            int topicId_Last_px;
                                            if (reverseTopicIdMap.TryGetValue("PX", out topicId_Last_px))
                                            {
                                                updateQueue.Enqueue(new RtdUpdateQueueItem(topicId_Last_px, "", update.GetNewValue(field)));
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    } catch (ArgumentException)
                    {
                        // Skip ...
                    }
                }
                if (updatesExist && (rtdUpdateEvent != null))
                {
                    // notify Excel that updates exist
                    // if this fails, it means that Excel is not ready
                    rtdUpdateEvent.UpdateNotify();
                    flowForm.AppendExcelLog("OnItemUpdate, Excel notified. HB interval: " + rtdUpdateEvent.HeartbeatInterval);
                }
            }
        }
Exemple #41
0
 public StreamingAccountData StreamingAccountDataUpdates(int itemPos, string itemName, IUpdateInfo update)
 {
     var streamingAccountData = new StreamingAccountData();
     try
     {
         var pnl = update.GetNewValue("PNL");
         var deposit = update.GetNewValue("DEPOSIT");
         var usedMargin = update.GetNewValue("USED_MARGIN");
         var amountDue = update.GetNewValue("AMOUNT_DUE");
         var availableCash = update.GetNewValue("AVAILABLE_CASH");
                                
         if (!String.IsNullOrEmpty(pnl))
         {
             streamingAccountData.ProfitAndLoss = Convert.ToDecimal(pnl);
         }
         if (!String.IsNullOrEmpty(deposit))
         {
             streamingAccountData.Deposit = Convert.ToDecimal(deposit);
         }
         if (!String.IsNullOrEmpty(usedMargin))
         {
             streamingAccountData.UsedMargin = Convert.ToDecimal(usedMargin);
         }
         if (!String.IsNullOrEmpty(amountDue))
         {
             streamingAccountData.AmountDue = Convert.ToDecimal(amountDue);
         }
         if (!String.IsNullOrEmpty(availableCash))
         {
             streamingAccountData.AmountDue = Convert.ToDecimal(availableCash);
         }
        
     }
     catch (Exception)
     {
     }
     return streamingAccountData;
 }
 public void OnUpdate(int itemPos, string itemName, IUpdateInfo update)
 {
     Console.WriteLine(NotifyUpdate(update) +
                     " for " + itemPos + ":" +
                     " key = " + update.GetNewValue(1) +
                     " command = " + update.GetNewValue(2) +
                     NotifyValue(update, 3, "qty"));
 }