Ejemplo n.º 1
0
        public async Task <RealTimeStockItem> GetRealTimeStockAsync(StockInfoItem stockItem)
        {
            GoogleStockClient  client    = new GoogleStockClient();
            RealTimeStockModel stockData = await client.QueryStockAsync(stockItem.Id);

            return(RealTimeStockItem.ConvertFrom(stockData));
        }
        public void QueryStockTest()
        {
            GoogleStockClient  query = new GoogleStockClient();
            RealTimeStockModel item  = query.QueryStockAsync("2115").GetAwaiter().GetResult();

            Assert.IsNotNull(item.CurrentPrice);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <param name="queryProvider">提供股票查詢的服務實體</param>
        /// <returns></returns>
        public static RealTimeStockItem ConvertFrom(RealTimeStockModel model)
        {
            double vol = -1;

            if (model.Volumes != null)
            {
                vol = Convert.ToDouble(model.Volumes.Replace(",", string.Empty));
            }

            return(new RealTimeStockItem()
            {
                Id = model.Id,
                Name = model.Name,
                ChangePercentage = model.ChangePercentage,
                CurrentPrice = model.CurrentPrice,
                ChangePrice = model.ChangePrice,
                HighestPrice = model.HighestPrice,
                LowestPrice = model.LowestPrice,
                LatestTime = model.QuerySystemTime,
                OpenPrice = model.OpenPrice,
                Volumes = Math.Truncate(vol),
                CurrentTimeVolumes = model.CurrentTimeVolumes,
                LimitUp = model.LimitUp,
                LimitDown = model.LimitDown,
                YesterdayPrice = model.YesterdayPrice,
                BuyPriceList = model.BuyPriceList,
                BuyQuantityList = model.BuyQuantityList,
                SellPriceList = model.SellPriceList,
                SellQuantityList = model.SellQuantityList,
                ExchangeTypeKey = model.ExchangeTypeKey
            });
        }
 private void SetUpDownLimitLineToChart(RealTimeStockModel stockMessage)
 {
     // Set the top and bottom value for the chart
     // *It Must set value before drawing the chart
     MiddleLineValue = Convert.ToDouble(stockMessage.YesterdayPrice);
     if (stockMessage.LimitUp != null && stockMessage.LimitDown != null)
     {
         TopLimitValue  = Convert.ToDouble(stockMessage.LimitUp);
         DownLimitValue = Convert.ToDouble(stockMessage.LimitDown);
     }
 }
        private void DrawExtraLines(RealTimeStockModel stockMessage)
        {
            List <ExtraLine> extraLines = new List <ExtraLine>
            {
                new ExtraLine {
                    Value = Convert.ToDouble(stockMessage.LimitUp)
                },
                new ExtraLine {
                    Value = Convert.ToDouble(stockMessage.YesterdayPrice)
                },
                new ExtraLine {
                    Value = Convert.ToDouble(stockMessage.LimitDown)
                }
            };

            _uiView.DrawExtraLine(extraLines);
        }