Пример #1
0
        private void ShowSpecificStockWindow(object sender, RoutedEventArgs e)
        {
            //if (txtSearch.SelectionLength == 0)
            //{
            //    MessageBox.Show("Please enter a stock");
            //}
            //else
            //{

            //}

            string    getURL       = "http://10.87.205.72:8080/MarketDataAnalyserWeb/rest/stocks/query";
            WebClient newWebClient = new WebClient();


            var    newSerializer  = new System.Web.Script.Serialization.JavaScriptSerializer();
            string receivedString = newWebClient.DownloadString(getURL + "?ticker=" + txtSearch.Text.ToString());
            Nasdaq newNasdaq      = newSerializer.Deserialize <Nasdaq>(receivedString);


            lblStockName.Content    = newNasdaq.ticker;
            lblOpeningPrice.Content = newNasdaq.openingPrice;
            lblClosingPrice.Content = newNasdaq.closingPrice;
            lblHigh.Content         = newNasdaq.high;
            lblLow.Content          = newNasdaq.low;
            lblVolume.Content       = newNasdaq.volume;
            //MessageBox.Show(newNasdaq.ToString());

            string getURLChart = "http://10.87.205.72:8080/MarketDataAnalyserWeb/rest/stocks/variation";

            string receivedStringChart = newWebClient.DownloadString(getURLChart + "/" +
                                                                     txtSearch.Text.ToString() + "/20110103/20110113");
            List <Nasdaq> newNasdaqList = newSerializer.Deserialize <List <Nasdaq> >(receivedStringChart);
            List <KeyValuePair <int, decimal> > newKeyValuePairChart = new List <KeyValuePair <int, decimal> >();

            for (int i = 0; i < newNasdaqList.Count; i++)
            {
                newKeyValuePairChart.Add(new KeyValuePair <int, decimal>(newNasdaqList[i].exchangeDate,
                                                                         newNasdaqList[i].closingPrice));
            }



            LineSeries newLineSeries = new LineSeries();

            newLineSeries.Title                = newNasdaq.ticker.ToString();
            newLineSeries.ItemsSource          = newKeyValuePairChart;
            newLineSeries.DependentValuePath   = "Value";
            newLineSeries.IndependentValuePath = "Key";
            lineChart.Series.Clear();
            lineChart.Series.Add(newLineSeries);
        }
Пример #2
0
        public string TestTheStockName()
        {
            string    getURL       = "http://10.87.198.158:8080/MarketDataAnalyserWeb/rest/stocks/NASDAQ/details";
            WebClient newWebClient = new WebClient();

            newWebClient.Proxy = null;

            string receivedString = newWebClient.DownloadString(getURL + "/" + Name);
            var    newSerializer  = new System.Web.Script.Serialization.JavaScriptSerializer();
            //  string receivedString = newWebClient.DownloadString(getURL + "/" + lstStocks.SelectedItem.ToString());
            Nasdaq newNasdaq = newSerializer.Deserialize <Nasdaq>(receivedString);

            return(newNasdaq.ticker.ToString());
        }
Пример #3
0
        private void LoadEverything(object sender, RoutedEventArgs e)
        {
            string    getURL       = "http://10.87.198.158:8080/MarketDataAnalyserWeb/rest/stocks";
            WebClient newWebClient = new WebClient();

            newWebClient.Proxy = null;

            try {
                Stream       receivedStream  = newWebClient.OpenRead(getURL);
                StockMarkets newStockMarkets = (StockMarkets)serializerStockMarkets.ReadObject(receivedStream);

                allStocks      = newStockMarkets.nasdaqStockList;
                allStocksLiffe = newStockMarkets.liffeStockList;
                allStocksForex = newStockMarkets.forexStockList;
                defaultStock   = newStockMarkets.defaultStock;

                //allStocks = (List<String>)serializerListString.ReadObject(receivedStream);
            }
            catch
            {
                MessageBox.Show("Server unavailable. Please check the connection.");
            }
        }
Пример #4
0
        private void ShowSpecificStockWindow(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrWhiteSpace(txtSearch.Text))
            {
                MessageBox.Show("Please enter a stock");
                txtSearch.Text = String.Empty;
            }
            else
            {
                try
                {
                    string    getURL       = "http://10.87.198.158:8080/MarketDataAnalyserWeb/rest/stocks/NASDAQ/details";
                    WebClient newWebClient = new WebClient();
                    newWebClient.Proxy = null;

                    greenArrow.Visibility = Visibility.Hidden;
                    redArrow.Visibility   = Visibility.Hidden;

                    var    newSerializer  = new System.Web.Script.Serialization.JavaScriptSerializer();
                    string receivedString = newWebClient.DownloadString(getURL + "/" + txtSearch.Text.ToString());
                    Nasdaq newNasdaq      = newSerializer.Deserialize <Nasdaq>(receivedString);



                    lblStockName.Content    = newNasdaq.ticker;
                    lblOpeningPrice.Content = newNasdaq.openingPrice;
                    lblClosingPrice.Content = newNasdaq.closingPrice;
                    lblHigh.Content         = newNasdaq.high;
                    lblLow.Content          = newNasdaq.low;
                    lblVolume.Content       = newNasdaq.volume;
                    lblTickerValue.Content  = Math.Abs(newNasdaq.upArrow);

                    if (Decimal.Compare(newNasdaq.upArrow, 0) >= 0)
                    {
                        greenArrow.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        redArrow.Visibility = Visibility.Visible;
                    }
                    //MessageBox.Show(newNasdaq.ToString());

                    string getURLChart = "http://10.87.198.158:8080/MarketDataAnalyserWeb/rest/stocks/NASDAQ/variation";

                    string receivedStringChart = newWebClient.DownloadString(getURLChart + "/" +
                                                                             txtSearch.Text.ToString());
                    newNasdaqList = newSerializer.Deserialize <List <Nasdaq> >(receivedStringChart);
                    List <KeyValuePair <int, decimal> > newKeyValuePairChart = new List <KeyValuePair <int, decimal> >();

                    for (int i = 0; i < newNasdaqList.Count; i++)
                    {
                        newKeyValuePairChart.Add(new KeyValuePair <int, decimal>(newNasdaqList[i].exchangeDate,
                                                                                 newNasdaqList[i].closingPrice));
                    }



                    LineSeries newLineSeries = new LineSeries();
                    newLineSeries.Title                = newNasdaq.ticker.ToString();
                    newLineSeries.ItemsSource          = newKeyValuePairChart;
                    newLineSeries.DependentValuePath   = "Value";
                    newLineSeries.IndependentValuePath = "Key";
                    lineChart.Series.Clear();
                    lineChart.Series.Add(newLineSeries);
                    lineChart.Title = "Price Trend";
                }
                catch
                {
                    MessageBox.Show("Stock does not exist");
                }
            }
        }
Пример #5
0
        private void ShowDefaultStock(object sender, RoutedEventArgs e)
        {
            try
            {
                string    getURL       = "http://10.87.198.158:8080/MarketDataAnalyserWeb/rest/stocks/NASDAQ/details";
                WebClient newWebClient = new WebClient();
                newWebClient.Proxy = null;

                greenArrow.Visibility = Visibility.Hidden;
                redArrow.Visibility   = Visibility.Hidden;


                var    newSerializer  = new System.Web.Script.Serialization.JavaScriptSerializer();
                string receivedString = newWebClient.DownloadString(getURL + "/AAPL");
                Nasdaq newNasdaq      = newSerializer.Deserialize <Nasdaq>(receivedString);

                // Nasdaq newTempNasdaq = LoginWindow.defaultStock;

                lblStockName.Content    = "CITI";
                lblOpeningPrice.Content = newNasdaq.openingPrice;
                lblClosingPrice.Content = newNasdaq.closingPrice;
                lblHigh.Content         = newNasdaq.high;
                lblLow.Content          = newNasdaq.low;
                lblVolume.Content       = newNasdaq.volume;

                lblTickerValue.Content = Math.Abs(newNasdaq.upArrow);

                if (Decimal.Compare(newNasdaq.upArrow, 0) >= 0)
                {
                    greenArrow.Visibility = Visibility.Visible;
                }
                else
                {
                    redArrow.Visibility = Visibility.Visible;
                }
                //MessageBox.Show(newNasdaq.ToString());

                string getURLChart = "http://10.87.198.158:8080/MarketDataAnalyserWeb/rest/stocks/NASDAQ/variation";

                string        receivedStringChart  = newWebClient.DownloadString(getURLChart + "/" + newNasdaq.ticker.ToString());
                List <Nasdaq> newNasdaqListDefault = newSerializer.Deserialize <List <Nasdaq> >(receivedStringChart);
                List <KeyValuePair <int, decimal> > newKeyValuePairChart = new List <KeyValuePair <int, decimal> >();

                for (int i = 0; i < newNasdaqListDefault.Count; i++)
                {
                    newKeyValuePairChart.Add(new KeyValuePair <int, decimal>(newNasdaqListDefault[i].exchangeDate,
                                                                             newNasdaqListDefault[i].closingPrice));
                }



                LineSeries newLineSeries = new LineSeries();
                newLineSeries.Title                = "CITI";
                newLineSeries.ItemsSource          = newKeyValuePairChart;
                newLineSeries.DependentValuePath   = "Value";
                newLineSeries.IndependentValuePath = "Key";
                lineChart.Series.Clear();
                lineChart.Series.Add(newLineSeries);
                lineChart.Title = "Price Trend";
            }
            catch
            {
                MessageBox.Show("Server unavailable. Please check the connection.");
            }
        }
        private void ChangeSelection(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                if (lstStocks.SelectedIndex == -1)
                {
                    return;
                }

                else
                {
                    greenArrow.Visibility = Visibility.Hidden;
                    redArrow.Visibility   = Visibility.Hidden;


                    if (comboBoxExchange.SelectedItem.Equals("Nasdaq"))
                    {
                        string    getURL       = "http://10.87.198.158:8080/MarketDataAnalyserWeb/rest/stocks/NASDAQ/details";
                        WebClient newWebClient = new WebClient();
                        newWebClient.Proxy = null;


                        lblStockName.Content = lstStocks.SelectedItem;


                        var    newSerializer  = new System.Web.Script.Serialization.JavaScriptSerializer();
                        string receivedString = newWebClient.DownloadString(getURL + "/" + lstStocks.SelectedItem.ToString());
                        Nasdaq newNasdaq      = newSerializer.Deserialize <Nasdaq>(receivedString);


                        lblStockName.Content    = newNasdaq.ticker;
                        lblOpeningPrice.Content = newNasdaq.openingPrice;
                        lblClosingPrice.Content = newNasdaq.closingPrice;
                        lblHigh.Content         = newNasdaq.high;
                        lblLow.Content          = newNasdaq.low;
                        lblVolume.Content       = newNasdaq.volume;
                        lblTickerValue.Content  = Math.Abs(newNasdaq.upArrow);;

                        if (Decimal.Compare(newNasdaq.upArrow, 0) >= 0)
                        {
                            greenArrow.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            redArrow.Visibility = Visibility.Visible;
                        }


                        string getURLChart = "http://10.87.198.158:8080/MarketDataAnalyserWeb/rest/stocks/NASDAQ/variation";

                        string receivedStringChart = newWebClient.DownloadString(getURLChart + "/" +
                                                                                 lstStocks.SelectedItem.ToString());

                        List <Nasdaq> newNasdaqList = newSerializer.Deserialize <List <Nasdaq> >(receivedStringChart);
                        List <KeyValuePair <int, decimal> > newKeyValuePairChart = new List <KeyValuePair <int, decimal> >();

                        for (int i = 0; i < newNasdaqList.Count; i++)
                        {
                            newKeyValuePairChart.Add(new KeyValuePair <int, decimal>(newNasdaqList[i].exchangeDate,
                                                                                     newNasdaqList[i].closingPrice));
                        }


                        LineSeries newLineSeries = new LineSeries();
                        newLineSeries.Title                = newNasdaq.ticker.ToString();
                        newLineSeries.ItemsSource          = newKeyValuePairChart;
                        newLineSeries.DependentValuePath   = "Value";
                        newLineSeries.IndependentValuePath = "Key";
                        lineChart.Series.Clear();
                        lineChart.Series.Add(newLineSeries);
                        lineChart.Title = "Price Trend";
                    }
                    else if (comboBoxExchange.SelectedItem.Equals("Nyse"))  //changed
                    {
                        string    getURL       = "http://10.87.198.158:8080/MarketDataAnalyserWeb/rest/stocks/FOREX/details";
                        WebClient newWebClient = new WebClient();
                        newWebClient.Proxy = null;


                        lblStockName.Content = lstStocks.SelectedItem;


                        var    newSerializer  = new System.Web.Script.Serialization.JavaScriptSerializer();
                        string receivedString = newWebClient.DownloadString(getURL + "/" + lstStocks.SelectedItem.ToString());
                        Forex  newNasdaq      = newSerializer.Deserialize <Forex>(receivedString);


                        lblStockName.Content    = newNasdaq.ticker;
                        lblOpeningPrice.Content = newNasdaq.openingPrice;
                        lblClosingPrice.Content = newNasdaq.closingPrice;
                        lblHigh.Content         = newNasdaq.high;
                        lblLow.Content          = newNasdaq.low;
                        lblVolume.Content       = newNasdaq.volume;
                        lblTickerValue.Content  = Math.Abs(newNasdaq.upArrow);;

                        if (Decimal.Compare(newNasdaq.upArrow, 0) >= 0)
                        {
                            greenArrow.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            redArrow.Visibility = Visibility.Visible;
                        }


                        string getURLChart = "http://10.87.198.158:8080/MarketDataAnalyserWeb/rest/stocks/FOREX/variation";

                        string receivedStringChart = newWebClient.DownloadString(getURLChart + "/" +
                                                                                 lstStocks.SelectedItem.ToString());

                        List <Forex> newNasdaqList = newSerializer.Deserialize <List <Forex> >(receivedStringChart);
                        List <KeyValuePair <int, decimal> > newKeyValuePairChart = new List <KeyValuePair <int, decimal> >();

                        for (int i = 0; i < newNasdaqList.Count; i++)
                        {
                            newKeyValuePairChart.Add(new KeyValuePair <int, decimal>(newNasdaqList[i].exchangeDate,
                                                                                     newNasdaqList[i].closingPrice));
                        }


                        LineSeries newLineSeries = new LineSeries();
                        newLineSeries.Title                = newNasdaq.ticker.ToString();
                        newLineSeries.ItemsSource          = newKeyValuePairChart;
                        newLineSeries.DependentValuePath   = "Value";
                        newLineSeries.IndependentValuePath = "Key";
                        lineChart.Series.Clear();
                        lineChart.Series.Add(newLineSeries);
                        lineChart.Title = "Price Trend";
                    }
                    else
                    {
                        string    getURL       = "http://10.87.198.158:8080/MarketDataAnalyserWeb/rest/stocks/LIFFE/details";
                        WebClient newWebClient = new WebClient();
                        newWebClient.Proxy = null;


                        lblStockName.Content = lstStocks.SelectedItem;


                        var    newSerializer  = new System.Web.Script.Serialization.JavaScriptSerializer();
                        string receivedString = newWebClient.DownloadString(getURL + "/" + lstStocks.SelectedItem.ToString());
                        Liffe  newNasdaq      = newSerializer.Deserialize <Liffe>(receivedString);


                        lblStockName.Content    = newNasdaq.ticker;
                        lblOpeningPrice.Content = newNasdaq.openingPrice;
                        lblClosingPrice.Content = newNasdaq.closingPrice;
                        lblHigh.Content         = newNasdaq.high;
                        lblLow.Content          = newNasdaq.low;
                        lblVolume.Content       = newNasdaq.volume;
                        lblTickerValue.Content  = Math.Abs(newNasdaq.upArrow);;

                        if (Decimal.Compare(newNasdaq.upArrow, 0) >= 0)
                        {
                            greenArrow.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            redArrow.Visibility = Visibility.Visible;
                        }


                        string getURLChart = "http://10.87.198.158:8080/MarketDataAnalyserWeb/rest/stocks/LIFFE/variation";

                        string receivedStringChart = newWebClient.DownloadString(getURLChart + "/" +
                                                                                 lstStocks.SelectedItem.ToString());

                        List <Liffe> newNasdaqList = newSerializer.Deserialize <List <Liffe> >(receivedStringChart);
                        List <KeyValuePair <int, decimal> > newKeyValuePairChart = new List <KeyValuePair <int, decimal> >();

                        for (int i = 0; i < newNasdaqList.Count; i++)
                        {
                            newKeyValuePairChart.Add(new KeyValuePair <int, decimal>(newNasdaqList[i].exchangeDate,
                                                                                     newNasdaqList[i].closingPrice));
                        }


                        LineSeries newLineSeries = new LineSeries();
                        newLineSeries.Title                = newNasdaq.ticker.ToString();
                        newLineSeries.ItemsSource          = newKeyValuePairChart;
                        newLineSeries.DependentValuePath   = "Value";
                        newLineSeries.IndependentValuePath = "Key";
                        lineChart.Series.Clear();
                        lineChart.Series.Add(newLineSeries);
                        lineChart.Title = "Price Trend";
                    }
                }
            }
            catch
            {
                MessageBox.Show("Server unavailable. Please check the connection.");
            }
        }
Пример #7
0
        private void CompareTheStocks(object sender, RoutedEventArgs e)
        {
            if (dateFrom.SelectedDate != null && dateTo.SelectedDate != null)
            {
                if (DateTime.Compare((DateTime)dateFrom.SelectedDate, (DateTime)dateTo.SelectedDate) < 1)
                {
                    greenArrowFirst.Visibility  = Visibility.Hidden;
                    redArrowFirst.Visibility    = Visibility.Hidden;
                    greenArrowSecond.Visibility = Visibility.Hidden;
                    redArrowSecond.Visibility   = Visibility.Hidden;

                    try
                    {
                        string    getURL       = "http://10.87.198.158:8080/MarketDataAnalyserWeb/rest/stocks/compareStocks";
                        WebClient newWebClient = new WebClient();


                        DateTime fromDate = (DateTime)dateFrom.SelectedDate;
                        DateTime toDate   = (DateTime)dateTo.SelectedDate;

                        var    newSerializer  = new System.Web.Script.Serialization.JavaScriptSerializer();
                        string receivedString = newWebClient.DownloadString(getURL + "/" + listBoxFirst.SelectedItem.ToString()
                                                                            + "/" + listBoxSecond.SelectedItem.ToString() + "/" + fromDate.ToString("yyyyMMdd")
                                                                            + "/" + toDate.ToString("yyyyMMdd"));
                        CompareStocks newCompareStocks = newSerializer.Deserialize <CompareStocks>(receivedString);


                        Nasdaq        newNasdaqFirst       = newCompareStocks.stock1;
                        Nasdaq        newNasdaqSecond      = newCompareStocks.stock2;
                        List <Nasdaq> newNasdaqChartFirst  = newCompareStocks.listStock1;
                        List <Nasdaq> newNasdaqChartSecond = newCompareStocks.listStock2;

                        lblStockNameFirst.Content    = newNasdaqFirst.ticker;
                        lblOpeningPriceFirst.Content = newNasdaqFirst.openingPrice;
                        lblClosingPriceFirst.Content = newNasdaqFirst.closingPrice;
                        lblHighFirst.Content         = newNasdaqFirst.high;
                        lblLowFirst.Content          = newNasdaqFirst.low;
                        lblVolumeFirst.Content       = newNasdaqFirst.volume;
                        lblTickerValueFirst.Content  = Math.Abs(newNasdaqFirst.upArrow);

                        if (Decimal.Compare(newNasdaqFirst.upArrow, 0) >= 0)
                        {
                            greenArrowFirst.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            redArrowFirst.Visibility = Visibility.Visible;
                        }

                        lblStockNameSecond.Content    = newNasdaqSecond.ticker;
                        lblOpeningPriceSecond.Content = newNasdaqSecond.openingPrice;
                        lblClosingPriceSecond.Content = newNasdaqSecond.closingPrice;
                        lblHighSecond.Content         = newNasdaqSecond.high;
                        lblLowSecond.Content          = newNasdaqSecond.low;
                        lblVolumeSecond.Content       = newNasdaqSecond.volume;
                        lblTickerValueSecond.Content  = Math.Abs(newNasdaqSecond.upArrow);

                        if (Decimal.Compare(newNasdaqSecond.upArrow, 0) >= 0)
                        {
                            greenArrowSecond.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            redArrowSecond.Visibility = Visibility.Visible;
                        }


                        List <KeyValuePair <int, decimal> > newKeyValuePairChartFirst = new List <KeyValuePair <int, decimal> >();

                        for (int i = 0; i < newNasdaqChartFirst.Count; i++)
                        {
                            newKeyValuePairChartFirst.Add(new KeyValuePair <int, decimal>(newNasdaqChartFirst[i].exchangeDate,
                                                                                          newNasdaqChartFirst[i].closingPrice));
                        }


                        LineSeries newLineSeriesFirst = new LineSeries();
                        newLineSeriesFirst.Title                = listBoxFirst.SelectedItem.ToString();
                        newLineSeriesFirst.ItemsSource          = newKeyValuePairChartFirst;
                        newLineSeriesFirst.DependentValuePath   = "Value";
                        newLineSeriesFirst.IndependentValuePath = "Key";
                        lineChart.Series.Clear();
                        lineChart.Series.Add(newLineSeriesFirst);

                        List <KeyValuePair <int, decimal> > newKeyValuePairChartSecond = new List <KeyValuePair <int, decimal> >();

                        for (int i = 0; i < newNasdaqChartSecond.Count; i++)
                        {
                            newKeyValuePairChartSecond.Add(new KeyValuePair <int, decimal>(newNasdaqChartSecond[i].exchangeDate,
                                                                                           newNasdaqChartSecond[i].closingPrice));
                        }


                        LineSeries newLineSeriesSecond = new LineSeries();
                        newLineSeriesSecond.Title                = listBoxSecond.SelectedItem.ToString();
                        newLineSeriesSecond.ItemsSource          = newKeyValuePairChartSecond;
                        newLineSeriesSecond.DependentValuePath   = "Value";
                        newLineSeriesSecond.IndependentValuePath = "Key";

                        lineChart.Series.Add(newLineSeriesSecond);
                        lineChart.Title = "Price Trend";
                    }
                    catch
                    {
                        MessageBox.Show("Server unavailable. Please check the connection.");
                    }
                }
                else
                {
                    MessageBox.Show("To-date is greater than From-date. Please select correct values. ");
                }
            }

            else
            {
                MessageBox.Show("Select dates");
            }
        }