Exemplo n.º 1
0
        public void loadHistoryData(DateTime sDate, DateTime eDate)
        {
            this.marketDataList_ = new List <IndexMarketData>();

            WebClient webClient = new WebClient();

            StringBuilder sb = new StringBuilder();

            string s_year  = (sDate.Year).ToString();
            string s_month = (sDate.Month - 1).ToString();
            string s_day   = (sDate.Day).ToString();
            string e_year  = (eDate.Year).ToString();
            string e_month = (eDate.Month - 1).ToString();
            string e_day   = (eDate.Day).ToString();

            foreach (var item in this.indexYahooTickerList_)
            {
                sb.Clear();

                sb.Append("http://ichart.yahoo.com/table.csv?s=%40%5EDJI," + item.Yahoo_ticker_ +
                          "&a=" + s_month +
                          "&b=" + s_day +
                          "&c=" + s_year +
                          "&d=" + e_month +
                          "&e=" + e_day +
                          "&f=" + e_year +
                          "&g=d&ignore=.csv");

                IndexHistoryMarketData ihmd = new IndexHistoryMarketData(item);

                string dataURL = sb.ToString();

                Stream       stream = webClient.OpenRead(dataURL);
                StreamReader reader = new StreamReader(stream);

                // 처음 한줄은 건너뜀
                var line = reader.ReadLine();

                while (!reader.EndOfStream)
                {
                    line = reader.ReadLine();
                    var values = line.Split(',');

                    DateTime d = DateTime.Parse(values[0]);

                    ihmd.TimeSeries_.Add(d.ToString("yyyyMMdd"), values[4]);
                }

                stream.Close();
                reader.Close();

                this.marketHistoryDataList_.Add(ihmd);
            }
        }
Exemplo n.º 2
0
        private void loadButton_Click(object sender, RoutedEventArgs e)
        {
            IndexTickerInfo item = this.definedIndexList_.SelectedItem as IndexTickerInfo;

            IndexHistoryMarketData ihmd = new IndexHistoryMarketData(item);

            DateTime sd = new DateTime(2014, 1, 1);
            DateTime ed = DateTime.Now;

            QLNet.TimeSeries <string> series = ihmd.historySeries(sd, ed);

            this.historyDataGrid_.ItemsSource = series;
        }
        public void historyUnderData(XmlWriter xmlWriter, DateTime issueDate, DateTime referenceDate)
        {
            //MarketDataLoaderFactory.CreateMarketLoader(

            foreach (var item in this.Excel_underlyingInfo_paraViewModel_)
            {
                IndexHistoryMarketData ihmd = new IndexHistoryMarketData(item.KrCode_);

                QLNet.TimeSeries <string> series = new QLNet.TimeSeries <string>();

                if (item.Excel_type_.ToUpper() == "INTERESTRATE")
                {
                    series = ihmd.historyCurveSeriesMRO(issueDate, referenceDate);
                }
                else
                {
                    series = ihmd.historySeriesMRO(issueDate, referenceDate);
                }

                xmlWriter.WriteStartElement("marketData");

                xmlWriter.WriteElementString("krcode", item.KrCode_);

                xmlWriter.WriteElementString("name", item.UnderNameTrans_.Value_);

                xmlWriter.WriteStartElement("dataValueInfo");

                foreach (var itemData in series)
                {
                    xmlWriter.WriteStartElement("dataValue");
                    DateTime d = itemData.Key;
                    xmlWriter.WriteElementString("date", d.ToString("yyyy-MM-dd"));
                    xmlWriter.WriteElementString("value", itemData.Value);
                    xmlWriter.WriteEndElement();
                }

                xmlWriter.WriteEndElement();

                xmlWriter.WriteEndElement();
            }
        }
        public string historyUnderData(DateTime effectiveDate, DateTime referenceDate, bool bodyOnly = false)
        {
            //Dictionary<string, QLNet.TimeSeries<string>> dataList = new Dictionary<string, QLNet.TimeSeries<string>>();

            StringBuilder sb = new StringBuilder();
            XmlWriterSettings setting = new XmlWriterSettings();

            setting.Indent = true;
            //setting.Encoding = Encoding.UTF8;

            if (bodyOnly == true)
                setting.OmitXmlDeclaration = true;

            XmlWriter xmlWriter = XmlWriter.Create(sb, setting);

            xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");

            xmlWriter.WriteStartElement("hisoryData");
                

            foreach (var item in this.excel_underlyingInfoViewModel_)
            {
                IndexHistoryMarketData ihmd = new IndexHistoryMarketData(item.KrCode_);

                QLNet.TimeSeries<string> series = new QLNet.TimeSeries<string>();

                if (item.Excel_type_.ToUpper() == "INTERESTRATE" || item.Excel_type_.ToUpper() == "EXCEL_INTERESTRATE")
                {
                    ihmd.Tenor_ = ((Excel_interestRateViewModel)item).Tenor_;
                    ihmd.LinkedCurveCode_ = ((Excel_interestRateViewModel)item).LinkedCurveCode_;
                    series = ihmd.historyCurveSeriesMRO(effectiveDate, referenceDate);
                }
                else
                {
                    series = ihmd.historySeriesMRO(effectiveDate, referenceDate);
                }

                xmlWriter.WriteStartElement("marketData");

                xmlWriter.WriteElementString("krcode", item.KrCode_);

                xmlWriter.WriteElementString("name", item.NameTrans_.Value_);

                xmlWriter.WriteStartElement("dataValueInfo");

                foreach (var itemData in series)
                {
                    xmlWriter.WriteStartElement("dataValue");
                    DateTime d = itemData.Key;
                    xmlWriter.WriteElementString("date", d.ToString("yyyy-MM-dd"));
                    xmlWriter.WriteElementString("value", itemData.Value);
                    xmlWriter.WriteEndElement();
                }

                xmlWriter.WriteEndElement();

                xmlWriter.WriteEndElement();

            }

            xmlWriter.WriteEndElement();

            xmlWriter.Close();

            return sb.ToString();
        }
        private void loadButton_Click(object sender, RoutedEventArgs e)
        {
            IndexTickerInfo item = this.definedIndexList_.SelectedItem as IndexTickerInfo;

            IndexHistoryMarketData ihmd = new IndexHistoryMarketData(item);

            DateTime sd = new DateTime(2014, 1, 1);
            DateTime ed = DateTime.Now;
            QLNet.TimeSeries<string> series = ihmd.historySeries(sd, ed);

            this.historyDataGrid_.ItemsSource = series;

        }
        public void loadHistoryData(DateTime sDate, DateTime eDate)
        {
            this.marketDataList_ = new List<IndexMarketData>();

            WebClient webClient = new WebClient();

            StringBuilder sb = new StringBuilder();

            string s_year = (sDate.Year).ToString();
            string s_month = (sDate.Month -1).ToString();
            string s_day = (sDate.Day).ToString();
            string e_year = (eDate.Year).ToString();
            string e_month = (eDate.Month - 1).ToString();
            string e_day = (eDate.Day).ToString();

            foreach (var item in this.indexYahooTickerList_)
            {
                sb.Clear();

                sb.Append("http://ichart.yahoo.com/table.csv?s=%40%5EDJI," + item.Yahoo_ticker_ +
                    "&a=" + s_month +
                    "&b=" + s_day +
                    "&c=" + s_year +
                    "&d=" + e_month +
                    "&e=" + e_day +
                    "&f=" + e_year +
                    "&g=d&ignore=.csv");

                IndexHistoryMarketData ihmd = new IndexHistoryMarketData(item);

                string dataURL = sb.ToString();

                Stream stream = webClient.OpenRead(dataURL);
                StreamReader reader = new StreamReader(stream);

                // 처음 한줄은 건너뜀
                var line = reader.ReadLine();

                while (!reader.EndOfStream)
                {
                    line = reader.ReadLine();
                    var values = line.Split(',');
                    
                    DateTime d = DateTime.Parse(values[0]);

                    ihmd.TimeSeries_.Add(d.ToString("yyyyMMdd"), values[4]);

                }

                stream.Close();
                reader.Close();

                this.marketHistoryDataList_.Add(ihmd);

            }

        }
        public void historyUnderData(XmlWriter xmlWriter, DateTime issueDate, DateTime referenceDate)
        {
            //MarketDataLoaderFactory.CreateMarketLoader(

            foreach (var item in this.Excel_underlyingInfo_paraViewModel_)
            {
                IndexHistoryMarketData ihmd = new IndexHistoryMarketData(item.KrCode_);

                QLNet.TimeSeries<string> series = new QLNet.TimeSeries<string>();

                if (item.Excel_type_.ToUpper() == "INTERESTRATE")
                {
                    series = ihmd.historyCurveSeriesMRO(issueDate, referenceDate);
                }
                else 
                {
                    series = ihmd.historySeriesMRO(issueDate, referenceDate);
                }

                xmlWriter.WriteStartElement("marketData");

                    xmlWriter.WriteElementString("krcode", item.KrCode_);

                    xmlWriter.WriteElementString("name", item.UnderNameTrans_.Value_);

                    xmlWriter.WriteStartElement("dataValueInfo");

                    foreach (var itemData in series)
                    {
                        xmlWriter.WriteStartElement("dataValue");
                        DateTime d = itemData.Key;
                        xmlWriter.WriteElementString("date", d.ToString("yyyy-MM-dd"));
                        xmlWriter.WriteElementString("value", itemData.Value);
                        xmlWriter.WriteEndElement();
                    }

                    xmlWriter.WriteEndElement();

                xmlWriter.WriteEndElement();

            }
        }
        public string historyUnderData(DateTime effectiveDate, DateTime referenceDate, bool bodyOnly = false)
        {
            //Dictionary<string, QLNet.TimeSeries<string>> dataList = new Dictionary<string, QLNet.TimeSeries<string>>();

            StringBuilder     sb      = new StringBuilder();
            XmlWriterSettings setting = new XmlWriterSettings();

            setting.Indent = true;
            //setting.Encoding = Encoding.UTF8;

            if (bodyOnly == true)
            {
                setting.OmitXmlDeclaration = true;
            }

            XmlWriter xmlWriter = XmlWriter.Create(sb, setting);

            xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");

            xmlWriter.WriteStartElement("hisoryData");


            foreach (var item in this.excel_underlyingInfoViewModel_)
            {
                IndexHistoryMarketData ihmd = new IndexHistoryMarketData(item.KrCode_);

                QLNet.TimeSeries <string> series = new QLNet.TimeSeries <string>();

                if (item.Excel_type_.ToUpper() == "INTERESTRATE" || item.Excel_type_.ToUpper() == "EXCEL_INTERESTRATE")
                {
                    ihmd.Tenor_           = ((Excel_interestRateViewModel)item).Tenor_;
                    ihmd.LinkedCurveCode_ = ((Excel_interestRateViewModel)item).LinkedCurveCode_;
                    series = ihmd.historyCurveSeriesMRO(effectiveDate, referenceDate);
                }
                else
                {
                    series = ihmd.historySeriesMRO(effectiveDate, referenceDate);
                }

                xmlWriter.WriteStartElement("marketData");

                xmlWriter.WriteElementString("krcode", item.KrCode_);

                xmlWriter.WriteElementString("name", item.NameTrans_.Value_);

                xmlWriter.WriteStartElement("dataValueInfo");

                foreach (var itemData in series)
                {
                    xmlWriter.WriteStartElement("dataValue");
                    DateTime d = itemData.Key;
                    xmlWriter.WriteElementString("date", d.ToString("yyyy-MM-dd"));
                    xmlWriter.WriteElementString("value", itemData.Value);
                    xmlWriter.WriteEndElement();
                }

                xmlWriter.WriteEndElement();

                xmlWriter.WriteEndElement();
            }

            xmlWriter.WriteEndElement();

            xmlWriter.Close();

            return(sb.ToString());
        }