Exemplo n.º 1
0
        public void LoadData(string path)
        {
            Tickers = new ObservableCollection <string>();
            List <Stock> Cache = new List <Stock>();

            if (File.Exists(path))
            {
                BackUpData(path);

                using (Stream stream = File.Open(path, FileMode.Open))
                {
                    var p = new StreamReader(stream);
                    while (!p.EndOfStream)
                    {
                        var c = p.ReadLine();
                        c = c + ".AX";
                        Tickers.Add(c);
                    }
                }
            }
            YahooApiInterface F = new YahooApiInterface();

            Cache.AddRange(F.getYahooData(new List <string>()
            {
                Tickers[Tickers.Count - 1], Tickers[0], Tickers[1]
            }, new DateTime(2013, 01, 01)));

            Back    = Cache[0];
            Current = Cache[1];
            Forward = Cache[2];
        }
Exemplo n.º 2
0
        public GraphControl()
        {
            Ticker = "sgh.AX";
            YahooApiInterface T   = new YahooApiInterface();
            List <Stock>      SGH = new List <Stock>(T.getYahooData(new List <string>()
            {
                Ticker
            }, new DateTime(2013, 01, 01)));

            update(SGH[0]);
            GenerateControls();
        }
Exemplo n.º 3
0
        public async void NextTikker()
        {
            string oldTick = Forward.StockName;

            Back    = Current;
            Current = Forward;
            Forward = null;

            await Task.Run(() =>
            {
                YahooApiInterface F = new YahooApiInterface();
                List <Stock> G      = new List <Stock>();

                int i = Tickers.IndexOf(oldTick) + 1;
                if (i == Tickers.Count)
                {
                    i = 0;
                }

                G = F.getYahooData(new List <string>()
                {
                    Tickers[i]
                }, new DateTime(2013, 01, 01));

                while (G[0].WeeklyHist == null || G[0].HourlyHist == null || G[0].DailyHist == null || G[0].MonthlyHist == null)
                {
                    i = Tickers.IndexOf(G[0].StockName);
                    Tickers.Remove(G[0].StockName);
                    if (i == Tickers.Count)
                    {
                        i = 0;
                    }
                    G = new List <Stock>();
                    G.AddRange(F.getYahooData(new List <string>()
                    {
                        Tickers[i]
                    }, new DateTime(2013, 01, 01)));
                }
                Forward = G[0];
            });
        }
Exemplo n.º 4
0
        public MetaData()
        {
            Tickers = new ObservableCollection <string>();
            List <Stock> Cache     = new List <Stock>();
            string       Stocklist = "";

            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.DefaultExt = ".csv";
            bool?result = dlg.ShowDialog();

            if (dlg.FileName != null)
            {
                Stocklist = dlg.FileName;

                if (File.Exists(Stocklist))
                {
                    BackUpData(Stocklist);

                    using (Stream stream = File.Open(Stocklist, FileMode.Open))
                    {
                        var p = new StreamReader(stream);
                        while (!p.EndOfStream)
                        {
                            var c = p.ReadLine();
                            c = c + ".AX";
                            Tickers.Add(c);
                        }
                    }
                }
                YahooApiInterface F = new YahooApiInterface();
                Cache.AddRange(F.getYahooData(new List <string>()
                {
                    Tickers[Tickers.Count - 1], Tickers[0], Tickers[1]
                }, new DateTime(2013, 01, 01)));

                Back    = Cache[0];
                Current = Cache[1];
                Forward = Cache[2];
            }
        }