예제 #1
0
 //说明:为什么没有把这些更新放到相应的类里是因为apiManager只出现在Markets这个类中!
 private void UpdateExchangeTickers(TickersByExchange exchangeTickers)
 {
     foreach (var ticker in exchangeTickers)
     {
         ITickerApi tickerUpdater = apiManager.GetApi <ITickerApi>(ticker.Exchange.AbbrName);
         var        refTicker     = ticker;
         tickerUpdater.UpdateTicker(ref refTicker);
     }
 }
예제 #2
0
        private void TimerOnTick(object sender, EventArgs e)
        {
            foreach (var alert in Alerts)
            {
                foreach (var item in alert.AbbrNamePrices)
                {
                    ITickerApi  tickerApi   = apiManager.GetApi <ITickerApi>(item.AbbrName);
                    ExchangeApi exchangeApi = apiManager.GetApi <ExchangeApi>(item.AbbrName);
                    Ticker      ticker      = exchangeApi.SelectedTickers[alert.PairCode];
                    tickerApi.UpdateTicker(ref ticker);
                    decimal price = Utility.GetPrice(alert.PriceType, ticker);
                    item.Price = price;
                }

                if (!alert.IsOpen)
                {
                    alert.State           = MonitorState.Pause;
                    alert.BackgroundColor = Colors.Transparent;
                    continue;
                }


                if (alert.IsHighThan)
                {
                    var prices = from priceItem in alert.AbbrNamePrices where priceItem.Price != 0 select priceItem.Price;
                    alert.Price = prices.Max();
                    if (alert.Price > alert.ComparePrice)
                    {
                        alert.State           = MonitorState.Triggered;
                        alert.BackgroundColor = alert.AlertColor;
                        PlaySound(alert);
                    }
                    else
                    {
                        alert.State           = MonitorState.NotTriggered;
                        alert.BackgroundColor = Colors.Transparent;
                    }
                }
                else
                {
                    var prices = from priceItem in alert.AbbrNamePrices where priceItem.Price != 0 select priceItem.Price;
                    alert.Price = prices.Min();
                    if (alert.Price < alert.ComparePrice)
                    {
                        alert.State           = MonitorState.Triggered;
                        alert.BackgroundColor = alert.AlertColor;
                        PlaySound(alert);
                    }
                    else
                    {
                        alert.State           = MonitorState.NotTriggered;
                        alert.BackgroundColor = Colors.Transparent;
                    }
                }
            }
        }
예제 #3
0
        private void TimerOnTick(object sender, EventArgs e)
        {
            foreach (var item in Alerts)
            {
                Ticker     ticker1    = GetTicker(item, item.Exchange1AbbrName);
                ITickerApi tickerApi1 = apiManager.GetApi <ITickerApi>(item.Exchange1AbbrName);
                tickerApi1.UpdateTicker(ref ticker1);
                item.Price1 = Utility.GetPrice(item.PriceType1, ticker1);

                Ticker     ticker2    = GetTicker(item, item.Exchange2AbbrName);
                ITickerApi tickerApi2 = apiManager.GetApi <ITickerApi>(item.Exchange2AbbrName);
                tickerApi2.UpdateTicker(ref ticker2);
                item.Price2 = Utility.GetPrice(item.PriceType2, ticker2);

                if (!item.IsOpen)
                {
                    item.State           = MonitorState.Pause;
                    item.BackgroundColor = Colors.Transparent;
                    continue;
                }

                if (item.Price1 == 0m || item.Price2 == 0m)
                {
                    item.State           = MonitorState.DataError;
                    item.BackgroundColor = Colors.Gray;
                    continue;
                }

                if (item.CurrentDifference > item.PriceDifference)
                {
                    item.State           = MonitorState.Triggered;
                    item.BackgroundColor = item.AlertColor;
                    if (item.IsPlaySound)
                    {
                        MediaPlayer player = new MediaPlayer();
                        Uri         uri    = new Uri("Media\\" + item.SoundFile, UriKind.Relative);
                        player.Open(uri);
                        player.Play();
                    }
                }
                else
                {
                    item.State           = MonitorState.NotTriggered;
                    item.BackgroundColor = Colors.Transparent;
                }
            }
        }
예제 #4
0
        private void TimerOnTick(object sender, EventArgs e)
        {
            foreach (var item in Alerts)
            {
                ITickerApi  tickerApi   = apiManager.GetApi <ITickerApi>(item.ExchangeAbbrName);
                ExchangeApi exchangeApi = apiManager.GetApi <ExchangeApi>(item.ExchangeAbbrName);
                Ticker      ticker      = exchangeApi.SelectedTickers[item.PairCode];
                tickerApi.UpdateTicker(ref ticker);
                item.Price = Utility.GetPrice(item.PriceType, ticker);


                if (!item.IsOpen)
                {
                    item.State           = MonitorState.Pause;
                    item.BackgroundColor = Colors.Transparent;
                    continue;
                }

                if (item.Price == 0m)
                {
                    item.State           = MonitorState.DataError;
                    item.BackgroundColor = Colors.Gray;
                    continue;
                }

                if (item.IsHighThan)
                {
                    if (item.Price > item.ComparePrice)
                    {
                        item.State           = MonitorState.Triggered;
                        item.BackgroundColor = item.AlertColor;
                        if (item.IsPlaySound)
                        {
                            MediaPlayer player = new MediaPlayer();
                            Uri         uri    = new Uri("Media\\" + item.SoundFile, UriKind.Relative);
                            player.Open(uri);
                            player.Play();
                        }
                    }
                    else
                    {
                        item.State           = MonitorState.NotTriggered;
                        item.BackgroundColor = Colors.Transparent;
                    }
                }
                else
                {
                    if (item.Price < item.ComparePrice)
                    {
                        item.State           = MonitorState.Triggered;
                        item.BackgroundColor = item.AlertColor;
                        if (item.IsPlaySound)
                        {
                            MediaPlayer player = new MediaPlayer();
                            Uri         uri    = new Uri("Media\\" + item.SoundFile, UriKind.Relative);
                            player.Open(uri);
                            player.Play();
                        }
                    }
                    else
                    {
                        item.State           = MonitorState.NotTriggered;
                        item.BackgroundColor = Colors.Transparent;
                    }
                }
            }
        }
예제 #5
0
 public ChronitonController(ISingularity singularity, ITickerRepository marketCapDataInfosRepository, ITickerApi tickerApi)
 {
     _singularity = singularity;
     _marketCapDataInfosRepository = marketCapDataInfosRepository;
     _tickerApi = tickerApi;
 }