Exemplo n.º 1
0
        public static MarketBasket FromURL(string url)
        {
            MarketBasket b = NYSEFromURL(url);

            b.Add(NASDAQFromURL(url));
            return(b);
        }
Exemplo n.º 2
0
        public MarketBasket URL()
        {
            MarketBasket mb = new MarketBasket();

            if (!Uri.IsWellFormedUriString(_url, UriKind.RelativeOrAbsolute))
            {
                return(mb);
            }
            if (_nyse && _linkedonly)
            {
                mb.Add(Fetch.LinkedNYSEFromURL(_url));
            }
            else if (_nyse)
            {
                mb.Add(Fetch.NYSEFromURL(_url));
            }
            if (_nasd && _linkedonly)
            {
                mb.Add(Fetch.LinkedNASDAQFromURL(_url));
            }
            else if (_nasd)
            {
                mb.Add(Fetch.NASDAQFromURL(_url));
            }
            if (_xdupe)
            {
                mb = Fetch.RemoveDupe(mb);
            }
            return(mb);
        }
Exemplo n.º 3
0
        public void Multiple()
        {
            MarketBasket mb  = new MarketBasket(new string[] { "IBM", "LVS", "T", "GS", "MHS" });
            MarketBasket rem = new MarketBasket(new string[] { "LVS", "MHS" });

            Assert.That(mb.Count == 5);
            Assert.That(rem.Count == 2);
            mb.Subtract(rem);
            Assert.That(mb.Count == 3, mb.Count.ToString());
        }
Exemplo n.º 4
0
        public static MarketBasket NYSE(string ParseStocks)
        {
            MarketBasket    mb = new MarketBasket();
            MatchCollection mc = Regex.Matches(ParseStocks, @"\b[A-Z]{1,3}\b");

            for (int i = 0; i < mc.Count; i++)
            {
                mb.Add(new Stock(mc[i].Value.ToUpper()));
            }
            return(mb);
        }
Exemplo n.º 5
0
        public void Serialization()
        {
            MarketBasket mb = new MarketBasket();

            mb.Add(new Stock("IBM"));
            MarketBasket compare = MarketBasket.FromString(mb.ToString());

            Assert.That(compare.Count == 1);
            mb.Clear();
            compare = MarketBasket.FromString(mb.ToString());
            Assert.That(compare.Count == 0);
        }
Exemplo n.º 6
0
        public static MarketBasket RemoveUnlisted(MarketBasket input)
        {
            MarketBasket output = new MarketBasket();

            for (int i = 0; i < input.Count; i++)
            {
                if (NYSE.isListed(input[i].Symbol) || NASDAQ.isListed(input[i].Symbol))
                {
                    output.Add(input[i]);
                }
            }
            return(output);
        }
Exemplo n.º 7
0
        public static MarketBasket LinkedOnlyNASDAQ(string parsestring)
        {
            MarketBasket    mb     = new MarketBasket();
            string          regexp = @">[A-Z]{4}</a>";
            MatchCollection mc     = Regex.Matches(parsestring, regexp);

            for (int i = 0; i < mc.Count; i++)
            {
                string chunk = mc[i].Value;
                chunk = chunk.Replace("</a>", "");
                chunk = chunk.TrimStart('>');
                mb.Add(new Stock(chunk.ToUpper()));
            }
            return(mb);
        }
Exemplo n.º 8
0
        public static MarketBasket RemoveDupe(MarketBasket input)
        {
            List <string> cache  = new List <string>();
            MarketBasket  output = new MarketBasket();

            for (int i = 0; i < input.Count; i++)
            {
                if (!cache.Contains(input[i].Symbol))
                {
                    output.Add(input[i]);
                    cache.Add(input[i].Symbol);
                }
            }
            return(output);
        }
Exemplo n.º 9
0
        public void BasketBasics()
        {
            MarketBasket mb = new MarketBasket();

            Assert.That(mb != null);
            Stock i = new Stock("IBM");

            mb = new MarketBasket(i);
            Assert.That(mb.hasStock);
            mb.Remove(i);
            Assert.That(!mb.hasStock);
            mb.Add(new Stock("LVS"));
            Assert.That(mb.Get(0).Symbol == "LVS", mb[0].ToString());
            mb.Add(new Stock("IBM"));
            Assert.That(mb[1].Symbol == "IBM");
            MarketBasket newbasket = new MarketBasket(new Stock("FDX"));

            newbasket.Add(mb);
            mb.Clear();
            Assert.That(mb.Count == 0);
            Assert.That(newbasket.Count == 3);
        }
Exemplo n.º 10
0
        public MarketBasket FILE()
        {
            MarketBasket mb = new MarketBasket();

            if ((_file == "") || (_file == null))
            {
                return(mb);
            }
            System.IO.StreamReader sr = null;
            try
            {
                sr = new System.IO.StreamReader(_file);
            }
            catch (Exception) { return(mb); }
            string file = sr.ReadToEnd();

            if (_nyse && _linkedonly)
            {
                mb.Add(ParseStocks.LinkedOnlyNYSE(file));
            }
            else if (_nyse)
            {
                mb.Add(ParseStocks.NYSE(file));
            }
            if (_nasd && _linkedonly)
            {
                mb.Add(ParseStocks.LinkedOnlyNASDAQ(file));
            }
            else if (_nasd)
            {
                mb.Add(ParseStocks.NASDAQ(file));
            }
            if (_xdupe)
            {
                mb = Fetch.RemoveDupe(mb);
            }
            return(mb);
        }
Exemplo n.º 11
0
        private void okbut_Click(object sender, EventArgs e)
        {
            _ft.Name          = urlnamebox.Text;
            _ft.Url           = urlbox.Text;
            _ft.ParseNASD     = nasdaqbut.Checked;
            _ft.ParseNYSE     = nysebut.Checked;
            _ft.ClickableOnly = linkedonlybut.Checked;
            string username = "";

            if (FetchUsername != null)
            {
                username = FetchUsername();
            }
            _basket = _ft.Go(username);
            if (_basket.hasStock)
            {
                DialogResult = DialogResult.OK;
            }
            else
            {
                DialogResult = DialogResult.Abort;
            }
            this.Close();
        }