Example #1
0
        public void ReloadHistoryPriceTicker(int shareId)
        {
            SettingBLL sBLL     = new SettingBLL(_unit);
            ShareBLL   shareBLL = new ShareBLL(_unit);

            try
            {
                //remove existing tickers
                this.RemoveHistoryPriceTicker(shareId);

                int historyYear = int.Parse(sBLL.Get(s => s.Key ==
                                                     SettingKey.HistoryDataYears.ToString()).Single().Value);

                DateTime start = DateTime.Now.AddYears(-1 * historyYear);

                Share share = shareBLL.GetByID(shareId);

                this.UploadHistoryPriceTicker(share.Symbol, start, DateTime.Now);
            }
            catch (Exception ex)
            {
                LogHelper.Error(_log, ex.ToString());
                throw;
            }
        }
Example #2
0
        public void PopulateETFStatDetails(Share s, HtmlDocument doc)
        {
            ETFInfo info = new ETFInfo();

            var profileTableQuery = from t in doc.DocumentNode.Descendants("table")
                                    where t.Id == "yfncsumtab"
                                    select t;

            var profileTable = profileTableQuery.FirstOrDefault();

            if (profileTable != null)
            {
                var businessSummaryTableQuery = from t in profileTable.Descendants("table")
                                                where t.InnerText.Contains("Fund Overview")
                                                select t;
                var businessSummaryTable = businessSummaryTableQuery.FirstOrDefault();

                if (businessSummaryTable != null)
                {
                    var fundDetailTable = businessSummaryTable.NextSibling;

                    if (fundDetailTable != null)
                    {
                        var trLine = from tr in fundDetailTable.Descendants("tr")
                                     select tr;

                        var trLineArray = trLine.ToArray();

                        info.Category   = HttpUtility.HtmlDecode(trLineArray[1].LastChild.InnerText);
                        info.FundFamily = HttpUtility.HtmlDecode(trLineArray[2].LastChild.InnerText);

                        var netAssetString = HttpUtility.HtmlDecode(trLineArray[3].LastChild.InnerText);

                        netAssetString = netAssetString.Replace("M", "");

                        double netAsset;

                        if (double.TryParse(netAssetString, out netAsset))
                        {
                            info.NetAssetM = netAsset;
                        }


                        var yieldString = HttpUtility.HtmlDecode(trLineArray[4].LastChild.InnerText);

                        yieldString = yieldString.Replace("%", "");

                        double yield;

                        if (double.TryParse(yieldString, out yield))
                        {
                            info.YieldPercentage = yield;
                        }
                        info.InceptionDate = HttpUtility.HtmlDecode(trLineArray[5].LastChild.InnerText);
                    }

                    Share s2 = _sBLL.GetByID(s.Id);
                    s2.Industry = info.Category;
                    _sBLL.Update(s2);

                    ETFInfoBLL eBLL   = new ETFInfoBLL(_unit);
                    ETFInfo    eInfo2 = eBLL.GetByShareID(s.Id);

                    if (eInfo2 != null)
                    {
                        eInfo2.Category        = info.Category;
                        eInfo2.FundFamily      = info.FundFamily;
                        eInfo2.InceptionDate   = info.InceptionDate;
                        eInfo2.NetAssetM       = info.NetAssetM;
                        eInfo2.YieldPercentage = info.YieldPercentage;

                        eBLL.Update(eInfo2);
                    }
                    else
                    {
                        eInfo2         = info;
                        eInfo2.ShareId = s.Id;
                        eBLL.Create(eInfo2);
                    }
                }
            }
        }