void ITickerCollectionUpdateListener.OnUpdateTickerCollection(TickerCollection collection, bool useInvokeForUI) { ArbitrageInfo info = collection.Arbitrage; double prevProfits = info.MaxProfitUSD; double prevSpread = info.Spread; collection.IsUpdating = true; info.Calculate(); info.SaveExpectedProfitUSD(); collection.IsUpdating = false; bool checkMaxProfits = true; if (info.AvailableProfitUSD > 20) { SelectedCollection = collection; ShouldProcessArbitrage = true; checkMaxProfits = false; } var action = new Action(() => { if (this.bbAllCurrencies.Checked && prevSpread * info.Spread < 0) { RefreshGrid(); } else { RefreshGridRow(collection); } if (checkMaxProfits && info.MaxProfitUSD - prevProfits > 20) { ShowNotification(collection, prevProfits); } for (int i = 0; i < collection.Count; i++) { Ticker ticker = collection.Tickers[i]; if (ticker.OrderBook.BidHipeStarted || ticker.OrderBook.AskHipeStarted) { SendBoostNotification(ticker); } else if (ticker.OrderBook.BidHipeStopped || ticker.OrderBook.AskHipeStopped) { SendBoostStopNotification(ticker); } } }); if (useInvokeForUI && IsHandleCreated) { BeginInvoke(action); } else { action(); } }
void ITickerCollectionUpdateListener.OnUpdateTickerCollection(TickerCollection collection, bool useInvokeForUI) { collection.RequestOverdue = false; ArbitrageInfo info = collection.Arbitrage; double prevProfits = info.MaxProfitUSD; double prevSpread = info.Spread; collection.IsUpdating = true; info.Calculate(); info.SaveExpectedProfitUSD(); RaiseArbitrageChanged(collection); collection.IsUpdating = false; //for(int i = 0; i < collection.Count; i++) { // Ticker ticker = collection.Tickers[i]; // if(ticker.OrderBook.BidHipeStarted || ticker.OrderBook.AskHipeStarted) // SendBoostNotification(ticker); // else if(ticker.OrderBook.BidHipeStopped || ticker.OrderBook.AskHipeStopped) // SendBoostStopNotification(ticker); //} }