Ejemplo n.º 1
0
        public async void AddEntry(string ticker)
        {
            List <OneDayData> stockData = await IEXDataProxy.GetOneDayData(ticker);

            watchListEntries.Add(new WatchListEntry
            {
                Symbol        = ticker.ToUpper(),
                Price         = String.Format("{0:0.##}", stockData[stockData.Count - 1].close),
                PriceChange   = String.Format("{0:0.##}", stockData[stockData.Count - 1].close - stockData[0].open),
                PercentChange = String.Format("{0:0.##}", ((stockData[stockData.Count - 1].close - stockData[0].open) / stockData[0].open) * 100),
                TotalVolume   = String.Format("{0:0.#} K", stockData.Sum(item => item.volume) / 1000)
            });
        }
Ejemplo n.º 2
0
        private async void GenerateChart(string duration, string ticker = "void")
        {
            this.OhlcChart.DataContext   = "";
            this.secondChart.DataContext = "";

            // if (ticker == "void")
            //    ticker = ((ComboBoxItem)this.TickerSelector.SelectedItem).Content.ToString().ToLower();

            List <FinancialData> newData   = new List <FinancialData>();
            List <RootObject>    stockData = await IEXDataProxy.GetData(duration, ticker);

            foreach (var dataPoint in stockData)
            {
                DateTime nextDate = new DateTime();

                if (DateTime.TryParse(dataPoint.date, out nextDate))
                {
                    newData.Add(new FinancialData()
                    {
                        High  = dataPoint.high,
                        Open  = dataPoint.open,
                        Low   = dataPoint.low,
                        Close = dataPoint.close,
                        Date  = nextDate
                    });
                }
                else
                {
                    newData.Add(new FinancialData()
                    {
                        High  = dataPoint.high,
                        Open  = dataPoint.open,
                        Low   = dataPoint.low,
                        Close = dataPoint.close,
                        Date  = DateTime.Today
                    });
                }
            }

            this.OhlcChart.DataContext   = newData;
            this.secondChart.DataContext = newData;
        }