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) { } }
void IHandyTableListener.OnUpdate(int itemPos, string itemName, IUpdateInfo update) { // if all null values simply return. if (IsUpdateNull(update)) { return; } try { if (MessageReceived == null) { return; } TDto value = _messageConverter.Convert(update); var args = new MessageEventArgs <TDto>(_adapter, _channel + "." + _topic, value, _phase); MessageReceived(this, args); } catch (Exception ex) { Logger.Error(ex); // TODO: lightstreamer swallows errors thrown here - live with it or fix lightstreamer client code throw; } }
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(); } }
public override void OnUpdate(int itemPos, string itemName, IUpdateInfo update) { try { var posUpdate = L1LsPriceUpdateData(itemPos, itemName, update); var epic = itemName.Replace("L1:", ""); foreach (var position in _positionsViewModel.Positions) { if (position.Model.Epic == epic) { position.Model.Bid = posUpdate.Bid; position.Model.MarketStatus = posUpdate.MarketState; position.Model.Offer = posUpdate.Offer; position.Model.NetChange = posUpdate.Change; position.Model.PctChange = posUpdate.ChangePct; position.Model.Low = posUpdate.Low; position.Model.High = posUpdate.High; position.Model.Open = posUpdate.MidOpen; position.Model.LsItemName = itemName; } } } catch (Exception ex) { _positionsViewModel.UpdatePositionMessage(ex.Message); } }
//HACK: Is it working and is correct? private bool CompareVersions(IUpdateInfo updateInfo, string version) { if (updateInfo.Version == string.Empty) { return(false); } string updateVersion = updateInfo.Version.Split('-').GetValue(0).ToString(); string currentVersion = Info.version.Split('-').GetValue(0).ToString(); string[] _updateVersion = updateVersion.Split('.'); string[] _currentVersion = currentVersion.Split('.'); int updateMajor = int.Parse(_updateVersion[0]); int updateMinor = int.Parse(_updateVersion[1]); int updateBuild = int.Parse(_updateVersion[2]); int major = int.Parse(_currentVersion[0]); int minor = int.Parse(_currentVersion[1]); int build = int.Parse(_currentVersion[2]); if (updateMajor > major) { return(true); } if (updateMinor > minor) { return(true); } if (updateBuild > build) { return(true); } return(false); }
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); } }
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); } }
void IHandyTableListener.OnUpdate(int itemPos, string itemName, IUpdateInfo update) { if (update != null) { if (update.NumFields != 0) { if ((update.ToString().Replace(" ", "") == "[(null)]") || (update.ToString().Replace(" ", "") == "[null]")) { if (_lastUpdate.HasValue) { if ((DateTime.Now - _lastUpdate.Value).TotalSeconds < 10) { if (_nullUpdateCount++ % 5 == 0) { Log.Instance.WriteEntry("Ignored null update", System.Diagnostics.EventLogEntryType.Warning); } return; } _lastUpdate = DateTime.Now; _nullUpdateCount = 0; } else { _lastUpdate = DateTime.Now; return; } Log.Instance.WriteEntry("Null update, synchronizing positions...", System.Diagnostics.EventLogEntryType.Warning); Synchronize(); return; } Log.Instance.WriteEntry("Incoming position update: " + update.ToString()); bool updateProcessed = false; foreach (var item in _positions) { if (item.Value.OnUpdate(update)) { updateProcessed = true; break; } } foreach (var tradingSet in _tradingSets) { foreach (var pos in tradingSet.Value.Positions) { if (pos.OnUpdate(update)) { updateProcessed = true; break; } } } if (!updateProcessed) { Log.Instance.WriteEntry("Unexpected update, synchronizing positions... update: " + update.ToString(), System.Diagnostics.EventLogEntryType.Warning); Synchronize(); } } } }
/// <summary> /// 设置修改人信息 /// </summary> /// <param name="updateInfo">被赋值的实体</param> /// <param name="updateID">创建人ID</param> /// <param name="updateName">创建人名称</param> public static void SetUpdateInfo(this IUpdateInfo updateInfo, int?updateID = 0, string updateName = "") { updateInfo.UpdateIP = Req.GetIP(); updateInfo.UpdateAt = DateTime.Now; updateInfo.UpdateID = updateID; updateInfo.UpdateName = updateName; }
public override void OnUpdate(int itemPos, string itemName, IUpdateInfo update) { try { var browseUpdate = L1LsPriceUpdateData(itemPos, itemName, update); var epic = itemName.Replace("L1:", ""); foreach (var market in _browseViewModel.BrowseMarkets) { if (market.Model.Epic == epic) { market.Model.LsItemName = itemName; market.Model.Bid = browseUpdate.Bid; market.Model.Offer = browseUpdate.Offer; market.Model.NetChange = browseUpdate.Change; market.Model.PctChange = browseUpdate.ChangePct; market.Model.Low = browseUpdate.Low; market.Model.High = browseUpdate.High; market.Model.Open = browseUpdate.MidOpen; market.Model.MarketStatus = browseUpdate.MarketState; } } } catch (Exception ex) { //Display in text box.. _browseViewModel.BrowseData = ex.Message; } }
public override void OnUpdate(int itemPos, string itemName, IUpdateInfo update) { try { var wlmUpdate = L1LsPriceUpdateData(itemPos, itemName, update); var epic = itemName.Replace("L1:", ""); var model = _tradingService.Instruments.FirstOrDefault(m => m.Epic == epic); if (model != null) { model.Epic = epic; model.Bid = wlmUpdate.Bid; model.Offer = wlmUpdate.Offer; model.NetChange = wlmUpdate.Change; model.PctChange = wlmUpdate.ChangePct; model.Low = wlmUpdate.Low; model.High = wlmUpdate.High; model.Open = wlmUpdate.MidOpen; //_marketViewModel.UpdateTime = wlmUpdate.UpdateTime; model.MarketStatus = wlmUpdate.MarketState; } } catch (Exception ex) { } }
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); }
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(); } } }
public override void OnUpdate(int itemPos, string itemName, IUpdateInfo update) { try { _watchlistsViewModel.WatchlistL1PriceUpdates = L1PriceUpdates(itemPos, itemName, update); var wlmUpdate = L1LsPriceUpdateData(itemPos, itemName, update); var epic = itemName.Replace("L1:", ""); foreach (var watchlistItem in _watchlistsViewModel.WatchlistMarkets) { if (watchlistItem.Model.Epic == epic) { watchlistItem.Model.Epic = epic; watchlistItem.Model.Bid = wlmUpdate.Bid; watchlistItem.Model.Offer = wlmUpdate.Offer; watchlistItem.Model.NetChange = wlmUpdate.Change; watchlistItem.Model.PctChange = wlmUpdate.ChangePct; watchlistItem.Model.Low = wlmUpdate.Low; watchlistItem.Model.High = wlmUpdate.High; watchlistItem.Model.Open = wlmUpdate.MidOpen; watchlistItem.UpdateTime = wlmUpdate.UpdateTime; watchlistItem.Model.MarketStatus = wlmUpdate.MarketState; } } } catch (Exception ex) { _watchlistsViewModel.WatchlistL1PriceUpdates = ex.Message; } }
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); }
public override void OnUpdate(int itemPos, string itemName, IUpdateInfo update) { try { var ordUpdate = L1LsPriceUpdateData(itemPos, itemName, update); var epic = itemName.Replace("L1:", ""); foreach (var order in _ordersViewModel.Orders) { if (order.Model.Epic == epic) { order.Model.LsItemName = itemName; order.Model.Bid = ordUpdate.Bid; order.Model.Offer = ordUpdate.Offer; order.Model.NetChange = ordUpdate.Change; order.Model.PctChange = ordUpdate.ChangePct; order.Model.Low = ordUpdate.Low; order.Model.High = ordUpdate.High; order.Model.Open = ordUpdate.MidOpen; order.Model.MarketStatus = ordUpdate.MarketState; } } } catch (Exception ex) { // Display in text box. _ordersViewModel.OrderData = ex.Message; } }
private void Flow(IProgressWindow prgWin) { prgWin.AppendLog("获取信息中", 10); IUpdateInfo info = InfoGetter.Get(); prgWin.AppendLog("获取信息完毕,正在解析", 20); prgWin.SetUpdateContent(info.UpdateContent); IEnumerable <IFile> needUpdateFile = Differ.Diff(info.Files, GetLocalFiles()); if (needUpdateFile.Count() == 0) { prgWin.AppendLog("无需更新!", 100); Thread.Sleep(4000); prgWin.Finish(); return; } int downloadingFile = 0; Downloader.DownloadedAFile += (s, e) => { downloadingFile++; prgWin.SetProgress(20 + (100 / needUpdateFile.Count() * downloadingFile * 80)); prgWin.AppendLog($"正在下载并更新{downloadingFile}/{needUpdateFile.Count()}"); }; Downloader.Download(needUpdateFile); prgWin.AppendLog("结束,三秒后退出", 100); Thread.Sleep(3000); prgWin.Finish(); }
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; } }
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 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); }
public void OnUpdate(int itemPos, string itemName, IUpdateInfo update) { Console.WriteLine(NotifyUpdate(update) + " for " + itemName + ":" + NotifyValue(update, "last_price") + NotifyValue(update, "time") + NotifyValue(update, "pct_change")); }
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")); }
public void UpdateReceived(int ph, int itemPos, IUpdateInfo update) { if (ph != this.phase) { return; } demoForm.BeginInvoke(updateDelegate, new Object[] { itemPos, update }); }
public async Task DownloadUpdate(IUpdateInfo updateInfo) { Console.WriteLine("Downloading update..."); using (WebClient client = new WebClient()) { client.Headers.Add("Accept: text/html, application/xhtml+xml, */*"); client.Headers.Add("User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)"); await client.DownloadFileTaskAsync(updateInfo.DownloadURL, zipPath); } }
// <Summary> // Lighstreamer callback - Order price updates... // </Summary> public override void OnUpdate(int itemPos, string itemName, IUpdateInfo update) { try { _form.AppendStreamingDataMessage(GetL1Prices(itemPos, itemName, update)); } catch (Exception ex) { _form.AppendStreamingDataMessage(ex.Message); } }
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; }
/// <summary> /// /// </summary> /// <param name="baseDir"></param> /// <returns></returns> private static List <Inf> GetUpdateInfos(DirectoryInfo baseDir) { List <Inf> list = new List <Inf>(); FileInfo[] files = baseDir.GetFiles(); foreach (FileInfo file in files) { if (!string.Equals(".dll", file.Extension, StringComparison.OrdinalIgnoreCase) && !string.Equals(".exe", file.Extension, StringComparison.OrdinalIgnoreCase)) { continue; } try { Assembly ass = Assembly.LoadFrom(file.FullName); Type[] types = ass.GetTypes(); foreach (Type type in types) { try { if (!type.IsAbstract) { if (typeof(IUpdateInfo).IsAssignableFrom(type)) { IUpdateInfo ui = ass.CreateInstance(type.FullName) as IUpdateInfo; if (ui != null && !string.IsNullOrEmpty(ui.UpdateInfoURL)) { list.Add(new Inf(ui.GetType().Assembly.GetName().Name, ui.UpdateInfoURL, ass.GetName().Version)); } } } } catch (Exception) { } } } catch (ReflectionTypeLoadException rte) { foreach (Type type in rte.Types) { try { if (!type.IsAbstract) { if (typeof(IUpdateInfo).IsAssignableFrom(type)) { IUpdateInfo ui = type.Assembly.CreateInstance(type.FullName) as IUpdateInfo; if (ui != null && !string.IsNullOrEmpty(ui.UpdateInfoURL)) { list.Add(new Inf(ui.GetType().Assembly.GetName().Name, ui.UpdateInfoURL, type.Assembly.GetName().Version)); } } } } catch (Exception) { } } } catch (Exception) { } } return(list); }
/// <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); }
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); }
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"); } }
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); }
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 void OnUpdate(int itemPos, string itemName, IUpdateInfo update) { listener.OnItemUpdate(phase, itemPos, itemName, update); }
public void OnUpdate(int itemPos, string itemName, IUpdateInfo update) { this.slClient.UpdateReceived(this.phase, itemPos, update); }
public void OnUpdate(int itemPos, string itemName, IUpdateInfo update) { //listener.OnItemUpdate(phase, itemPos, itemName, update); Debug.WriteLine(update.ToString()); }
public virtual void OnUpdate(int itemPos, string itemName, IUpdateInfo update) { }
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")); }
public string GetL1Prices(int itemPos, string itemName, IUpdateInfo update) { return L1PriceUpdates(itemPos, itemName, update); }
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 L1LsPriceData GetL1PricesData(int itemPos, string itemName, IUpdateInfo update) { return L1LsPriceUpdateData(itemPos, itemName, update); }
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 bool OnUpdate(IUpdateInfo update) { if (update == null) return false; if (update.NumFields == 0) return false; JavaScriptSerializer json_serializer = new JavaScriptSerializer(); if ((update.ToString().Replace(" ", "") == "[(null)]") || (update.ToString().Replace(" ", "") == "[null]")) return false; Log.Instance.WriteEntry("Incoming position update: " + update.ToString()); var json = json_serializer.DeserializeObject(update.ToString()); if (json.GetType().ToString() == "System.Object[]") { object[] objs = (object[])json; if (objs != null) { foreach (var obj in objs) { var trade_notification = (Dictionary<string, object>)obj; if (trade_notification != null) { if (trade_notification["channel"].ToString() != "PublicRestOTC") { Log.Instance.WriteEntry("Incoming trade from a different channel: " + trade_notification["channel"].ToString(), System.Diagnostics.EventLogEntryType.Information); return false; } if (trade_notification["epic"].ToString() == _name) { if (trade_notification["dealStatus"].ToString() == "ACCEPTED") { if (trade_notification["status"].ToString() == "OPEN") { if (!openTrade(trade_notification)) { Log.Instance.WriteEntry("Could not process an open order: " + update.ToString(), System.Diagnostics.EventLogEntryType.Error); return false; } return true; } else if (trade_notification["status"].ToString() == "DELETED") { if (!closeTrade(trade_notification)) { Log.Instance.WriteEntry("Could not process an close order: " + update.ToString(), System.Diagnostics.EventLogEntryType.Error); return false; } return true; } } else { // deal rejected return rejectTrade(trade_notification); } } } } } } return false; }
private string NotifyUpdate(IUpdateInfo update) { return update.Snapshot ? "snapshot" : "update"; }
public void UpdateReceived(int ph, int itemPos, IUpdateInfo update) { lock (this) { if (ph != this.phase) { return; } demoForm.Invoke(updateDelegate, new Object[] { itemPos, update }); } }
public override void OnUpdate(int itemPos, string itemName, IUpdateInfo update) { try { L1LsPriceData priceData = L1LsPriceUpdateData(itemPos, itemName, update); foreach (var data in (from MarketData mktData in MarketData where itemName.Contains(mktData.Id) select mktData).ToList()) { var curTime = Config.ParseDateTimeUTC(priceData.UpdateTime); if (Config.PublishingOpen(curTime)) data.FireTick(curTime, priceData); // Timestamps from IG are GMT (i.e. equivalent to UTC) } } catch (SEHException exc) { Log.Instance.WriteEntry("Market data update interop error: " + exc.ToString() + ", Error code: " + exc.ErrorCode, EventLogEntryType.Error); } catch (Exception ex) { Log.Instance.WriteEntry("Market data update error: " + ex.ToString(), System.Diagnostics.EventLogEntryType.Error); throw; } }
private void UpdateLogs(object sender, IUpdateInfo messages) { Dispatcher.BeginInvoke(new Action(() => { ExecutionBar.Value += messages.GetCounter; if (!(bool)UpdatePBOnly.IsChecked || ExecutionBar.Value>=ExecutionBar.Maximum) { AddLog(messages.GetMessage); AddLog("Files copied: " + ExecutionBar.Value + "/" + ExecutionBar.Maximum, false); } })); }
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); }
public override void OnUpdate(int itemPos, string itemName, IUpdateInfo update) { var accountUpdates = StreamingAccountDataUpdates(itemPos, itemName, update); if ((itemPos != 0) && (itemPos <= _applicationViewModel.Accounts.Count)) { var index = 0; // we are subscription to the current account ( which will be account index 0 ). _applicationViewModel.Accounts[index].AmountDue = accountUpdates.AmountDue; _applicationViewModel.Accounts[index].AvailableCash = accountUpdates.AvailableCash; _applicationViewModel.Accounts[index].Deposit = accountUpdates.Deposit; _applicationViewModel.Accounts[index].ProfitLoss = accountUpdates.ProfitAndLoss; _applicationViewModel.Accounts[index].UsedMargin = accountUpdates.UsedMargin; } }
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 IgPublicApiData.TradeSubscriptionModel UpdateTs(int itemPos, string itemName, IUpdateInfo update, string inputData, TradeSubscriptionType updateType) { var tsm = new IgPublicApiData.TradeSubscriptionModel(); try { var tradeSubUpdate = JsonConvert.DeserializeObject<LsTradeSubscriptionData>(inputData); tsm.DealId = tradeSubUpdate.dealId; tsm.AffectedDealId = tradeSubUpdate.affectedDealId; tsm.DealReference = tradeSubUpdate.dealReference; tsm.DealStatus = tradeSubUpdate.dealStatus.ToString(); tsm.Direction = tradeSubUpdate.direction.ToString(); tsm.ItemName = itemName; tsm.Epic = tradeSubUpdate.epic; tsm.Expiry = tradeSubUpdate.expiry; tsm.GuaranteedStop = tradeSubUpdate.guaranteedStop; tsm.Level = tradeSubUpdate.level; tsm.Limitlevel = tradeSubUpdate.limitLevel; tsm.Size = tradeSubUpdate.size; tsm.Status = tradeSubUpdate.status.ToString(); tsm.StopLevel = tradeSubUpdate.stopLevel; switch (updateType) { case TradeSubscriptionType.Opu: tsm.TradeType = "OPU"; break; case TradeSubscriptionType.Wou: tsm.TradeType = "WOU"; break; case TradeSubscriptionType.Confirm: tsm.TradeType = "CONFIRM"; break; } SmartDispatcher.BeginInvoke(() => { if (_applicationViewModel != null) { _applicationViewModel.UpdateDebugMessage("TradeSubscription received : " + tsm.TradeType); _applicationViewModel.TradeSubscriptions.Add(tsm); if ((tradeSubUpdate.affectedDeals != null) && (tradeSubUpdate.affectedDeals.Count > 0)) { foreach (var ad in tradeSubUpdate.affectedDeals) { var adm = new IgPublicApiData.AffectedDealModel { AffectedDeal_Id = ad.dealId, AffectedDeal_Status = ad.status }; _applicationViewModel.AffectedDeals.Add(adm); } } } }); } catch (Exception ex) { _applicationViewModel.ApplicationDebugData += ex.Message; } return tsm; }
private void CopyTo(FileInfo f, string outputFolder, ref int currentNumber, string outputMask, string numberOfDigits, bool overwriteFiles, HashSet<IMapEntry> map, bool updatePBOnly) { if (_cancellationToken != null && !_cancellationToken.IsCancellationRequested) { int currentNumberTemp = currentNumber; string newName = outputFolder + GetNewName(ref currentNumberTemp, outputMask, numberOfDigits); f.CopyTo(newName, overwriteFiles); map.Add(new MapEntry(new DirectoryInfo(f.FullName), new DirectoryInfo(newName))); currentNumber = currentNumberTemp; if (_progress != null) { if(_updateInfo==null) _updateInfo=new UpdateInfo(); _updateInfo.AddMessage(String.Format("File: {0} was copied as: {1}", f.FullName, newName)); if (_updateInfo.UpdateTime.AddMilliseconds(200)<System.DateTime.Now) { _progress.Report((IUpdateInfo)_updateInfo.Clone()); if (updatePBOnly) _updateInfo.ResetCounter(); else _updateInfo = null; } } } }
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 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(); }