/// <summary>
        /// Requests the current price for a list of stocks
        /// </summary>
        /// <param name="symbols">The symbols to get quotes for</param>
        /// <param name="callback">Callback executed with the results</param>
        public void GetQuote(List <string> symbols, DataAccessor.PriceDataCallback callback)
        {
            if ((symbols.Count > 0) && (Client.isAuthenticated))
            {
                Client.DownloadQuote(symbols).ContinueWith((results) =>
                {
                    // Put the data into a table
                    DataTable dt = new DataTable();
                    dt.Columns.Add("Symbol", typeof(string));
                    dt.Columns.Add("Price", typeof(decimal));

                    if (!results.IsFaulted && results.IsCompleted)
                    {
                        foreach (Quote p in results.Result)
                        {
                            if (p != null)
                            {
                                dt.Rows.Add(p.Symbol, (p.LastExtendedHoursTradePrice != null) ? p.LastExtendedHoursTradePrice : p.LastTradePrice);
                            }
                        }
                    }

                    // Send the results back
                    callback(dt);
                });
            }
            else
            {
                // Invalid request, but should still execute the callback
                callback(null);
            }
        }
Esempio n. 2
0
        public static void Main (string [] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Usage:");
                Console.WriteLine("RgQuote SYMBOL1 [SYMBOL2 SYMBOL3 SYMBOL_N]");
                Environment.Exit(1);
            }

            var rh = new RobinhoodClient();

            authenticate(rh).Wait();


            var quotes = rh.DownloadQuote(args).Result;

            Console.WriteLine(DateTime.Now);
            foreach (var q in quotes)
            {
                if (q == null)
                {
                    continue;
                }

                Console.WriteLine("{0}\tCh: {1}%\tLTP: {2}\tBID: {3}\tASK: {4}",
                                  q.Symbol,
                                  q.ChangePercentage,
                                  q.LastTradePrice,
                                  q.BidPrice,
                                  q.AskPrice);
            }
        }
Esempio n. 3
0
        public static void Main(string [] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Usage:");
                Console.WriteLine("RgQuote SYMBOL1 [SYMBOL2 SYMBOL3 SYMBOL_N]");
                Environment.Exit(1);
            }

            var rh = new RobinhoodClient();

            authenticate(rh).Wait();

            while (1 < 2)
            {
                var quotes = rh.DownloadQuote(args).Result;

                Console.WriteLine(DateTime.Now);
                foreach (var q in quotes)
                {
                    if (q == null)
                    {
                        continue;
                    }

                    Console.WriteLine("{0}\tCh: {1}%\tLTP: {2}\tBID: {3}\tASK: {4}",
                                      q.Symbol,
                                      q.ChangePercentage,
                                      q.LastTradePrice,
                                      q.BidPrice,
                                      q.AskPrice);
                }
            }
            Console.Read();
        }
Esempio n. 4
0
        private async void Speak(object sender, System.Windows.RoutedEventArgs e)
        {
            TaskbarItemInfo taskbarItemInfo = new TaskbarItemInfo();

            taskbarItemInfo.ProgressValue = .5;
            taskbarItemInfo.ProgressState = TaskbarItemProgressState.Paused;

            var args = new[] { "RgQuote", "F" }; // string[]

            var rh = new RobinhoodClient();

            await authenticate(rh);

            while (1 < 2)
            {
                var quotes = await rh.DownloadQuote(args);

                //Console.WriteLine(DateTime.Now);
                foreach (var q in quotes)
                {
                    if (q != null)
                    {
                        textToSpeech.Text = q.LastTradePrice.ToString();
                    }
                }
            }
        }
Esempio n. 5
0
        internal static async Task <Quote> GetQuote(string symbol)
        {
            try
            {
                var rh = new RobinhoodClient(_token);

                _quote = await rh.DownloadQuote(symbol).ConfigureAwait(continueOnCapturedContext: false);
            }
            catch (Exception exc)
            {
                Utils.MessageBoxModal(exc.ToString());
            }
            return(null);
        }
Esempio n. 6
0
        internal static async Task <Quote> AttemptToGetQuote(string symbol)
        {
            try
            {
                Utils.MessageBoxModal($"Attempting to get Quote for {symbol}...");

                var rh = new RobinhoodClient(_token);

                _results = await rh.DownloadQuote(symbol).ConfigureAwait(continueOnCapturedContext: false);

                _resultsLabel = symbol;

                Utils.MessageBoxModal("Quote succeeded.");
            }
            catch (Exception exc)
            {
                Utils.MessageBoxModal(exc.ToString());
            }
            return(null);
        }
Esempio n. 7
0
        public static async Task GetStockQuote(string symbol)
        {
            var rh = new RobinhoodClient(_token);

            _quote = await rh.DownloadQuote(symbol);
        }
Esempio n. 8
0
        public static void Main(string [] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Usage:");
                Console.WriteLine("RhQuote SYMBOL1 [SYMBOL2 SYMBOL3 SYMBOL_N]");
                Environment.Exit(1);
            }

            var rh = new RobinhoodClient();

            if (!authenticate(rh))
            {
                Console.WriteLine("Unable to authenticate user");
                Environment.Exit(1);
            }

            try
            {
                var quotes  = rh.DownloadQuote(args).Result;
                var history = rh.DownloadHistory(args, "5minute", "week").Result;
                Console.WriteLine(DateTime.Now);
                foreach (var q in quotes)
                {
                    if (q == null)
                    {
                        continue;
                    }

                    Console.WriteLine("{0}\tCh: {1}%\tLTP: {2}\tBID: {3}\tASK: {4}",
                                      q.Symbol,
                                      q.ChangePercentage,
                                      q.LastTradePrice,
                                      q.BidPrice,
                                      q.AskPrice);
                }
                foreach (var h in history)
                {
                    if (h == null)
                    {
                        continue;
                    }

                    Console.WriteLine("{0}\tInterval: {1}\tSpan: {2}\tBound: {3}",
                                      h.Symbol,
                                      h.Interval,
                                      h.Span,
                                      h.Bounds);
                    foreach (var p in h.HistoricalInfo)
                    {
                        Console.WriteLine("{0}\tOpen: {1}\tClose: {2}\tHigh: {3}\tLow: {3}",
                                          p.BeginsAt,
                                          p.OpenPrice,
                                          p.ClosePrice,
                                          p.HighPrice,
                                          p.LowPrice);
                    }
                }
            }
            catch
            {
                Console.WriteLine("None of the quotes entered were found.");
            }
        }
Esempio n. 9
0
        public static List <Stock> GetQuote(List <Stock> stocks = null)
        {
            List <Stock> newList = new List <Stock>();

            if (stocks.Count() > 0 && rh != null)
            {
                IList <Quote> quotes;
                try
                {
                    quotes = rh.DownloadQuote(stocks.Select(s => s.Ticker)).Result;
                }
                catch (Exception e)
                {
                    quotes = null;
                }
                //if (stocks == null)
                //  stocks = new List<Stock>();
                if (quotes != null)
                {
                    foreach (var q in quotes)
                    {
                        if (q is null)
                        {
                            continue;
                        }
                        Instrument instrument = rh.FindInstrument(q.Symbol).Result.FirstOrDefault(i => i.Symbol == q.Symbol);

                        if (instrument is null)
                        {
                            continue;
                        }

                        Stock stock = stocks.Find(s => s.Ticker == q.Symbol);

                        if (stock is null)
                        {
                            stock = new Stock();
                        }

                        stock.Ticker = q.Symbol;
                        //if (stock.Ticker != "AAPL" || stock.LastTradePrice < q.LastTradePrice)
                        stock.LastTradePrice = Math.Round(q.LastTradePrice, 2);
                        //if (stock.Ticker != "AAPL" )


                        stock.ChangePctng   = Math.Round(q.ChangePercentage, 2);
                        stock.AskPrice      = Math.Round(q.AskPrice, 2);
                        stock.BidPrice      = Math.Round(q.BidPrice, 2);
                        stock.InstrumentURL = instrument.InstrumentUrl.Uri.AbsoluteUri;
                        string chngSym = string.Empty;

                        if (q.ChangePercentage < 0)
                        {
                            stock.Color   = Color.IndianRed;
                            stock.ChngSym = "-";
                        }
                        else
                        {
                            stock.Color   = Color.SeaGreen;
                            stock.ChngSym = "+";
                        }

                        //return string.("{0}: ${1} ({2}{3}%)", stock.Ticker,
                        //    lastTradePrice.ToString(),
                        //    chngSym,
                        //    changePctng.ToString());

                        newList.Add(stock);
                    }
                    //NotifyPropertyChanged();
                }
            }
            return(newList);
        }