protected void UpdateTickers() { Exchange ex = Exchange.Get(ExchangeType.Tinkoff); if (!ex.Connect()) { return; } if (!ex.IsInitialized) { ex.InitializedChanged += OnExchangeInitialized; return; } if (WebTickers == null) { return; } try { Tickers.Clear(); ex.Tickers.ForEach(t => { TickerExchangeWebInfo nyse = WebTickers.Tickers.FirstOrDefault(n => (n.Exchange == "NYSE" || n.Exchange == "NASDAQ") && n.Ticker == t.Name); if (nyse != null) { TickerExchangeWebInfo xetra = WebTickers.Tickers.FirstOrDefault(n => n.Exchange == "Xetra" && n.Ticker == t.Name); TinkoffGapScannerInfo info = new TinkoffGapScannerInfo(); info.NyseTicker = nyse; info.XetraTicker = xetra; info.TinkoffTicker = (TinknoffInvestTicker)t; Tickers.Add(info); info.Updated += TickerUpdated; } }); } catch (Exception) { } finally { BeginInvoke(new MethodInvoker(() => { this.gridControl1.DataSource = Tickers; this.gridControl1.RefreshDataSource(); })); } }
private void TickerUpdated(object sender, EventArgs e) { TinkoffGapScannerInfo t = (TinkoffGapScannerInfo)sender; if (t.LastGapPerc != t.GapPerc && t.GapPerc > 0.8) { t.LastGapPerc = t.GapPerc; string text = string.Empty; text += "<b>gap detected</b> " + t.Ticker + " (" + t.Name + ")"; text += "<pre> nyse cp: " + t.NyseClosePrice + "</pre>"; text += "<pre> nyse am: " + t.NyseAfterMarketPrice + "</pre>"; text += "<pre> xetra: " + t.XetraPrice + "</pre>"; text += "<pre> bid: " + t.TinkoffInvestCurrentBid + "</pre>"; text += "<pre> gap: " + t.Gap + "</pre>"; text += "<pre> gap %: " + t.GapPerc + "</pre>"; TelegramBot.Default.SendNotification(text); } BeginInvoke(new Action <TinkoffGapScannerInfo>(UpdateTicker), (TinkoffGapScannerInfo)sender); }
void UpdateTicker(TinkoffGapScannerInfo t) { int rh = this.gridView1.GetRowHandle(Tickers.IndexOf(t)); this.gridView1.RefreshRow(rh); }