Beispiel #1
0
        public async Task <bool> QueryStock(StockProfile aStock)
        {
            if (!QueryYahooFinance(ref aStock))
            {
                return(false);
            }

            // Obsolete
            if (!QueryYahooFinanceProfile(ref aStock))
            {
                return(false);
            }

            //if ( aStock.Market == Enums.Market.US && !QueryReuters(ref aStock))
            //    return false;

            if (!QueryMorningStar(ref aStock))
            {
                return(false);
            }

            //if ( aStock.Market == Enums.Market.US)
            await QueryJitta(aStock);

            aStock.LastUpdate = DateTime.Now;

            return(true);
        }
Beispiel #2
0
        public void Add(StockProfile aStock)
        {
            if (isExist(aStock))
            {
                this.StockModel.Remove(GetStock(aStock.Sym, aStock.Mkt));
            }

            this.StockModel.Add(aStock);
        }
Beispiel #3
0
 public Boolean isExist(StockProfile aStock)
 {
     foreach (StockProfile nStock in this.StockModel.GetList())
     {
         if (nStock.Sym == aStock.Sym && nStock.Mkt == aStock.Mkt)
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #4
0
        public override void Render(System.Drawing.Graphics g, System.Drawing.Rectangle r)
        {
            base.Render(g, r);
            StockProfile nStock = (StockProfile)this.RowObject;

            if (nStock.JEP > nStock.Last)
            {
                g.FillRectangle(System.Drawing.Brushes.LightGreen, r);
                g.DrawString(this.GetText(), this.Font, System.Drawing.Brushes.Black, r, this.StringFormatForGdiPlus);
            }
        }
Beispiel #5
0
        private bool QueryReuters(ref StockProfile aStock)
        {
            String nReutersQueryStr = ReutersParser.QUERY_STR;

            nReutersQueryStr = nReutersQueryStr.Replace("@TICK", aStock.Sym);

            String        nReutersHtmlStr = RESTController.GetREST(nReutersQueryStr);
            ReutersParser nReutersParser  = new ReutersParser(aStock);

            if (nReutersParser.StartHTML(nReutersHtmlStr))
            {
                return(true);
            }

            return(false);
        }
Beispiel #6
0
 private void watchlistOLV_DoubleClick(object sender, EventArgs e)
 {
     if (watchlistOLV.SelectedItems.Count == 1)
     {
         StockProfile nStock = (StockProfile)watchlistOLV.SelectedObject;
         if (nStock.LastUpdate.Date == DateTime.Now.Date)
         {
             StockProfilingForm nForm = new StockProfilingForm(nStock);
             nForm.Show();
         }
         else
         {
             this.StockQuery(nStock, true);
         }
     }
 }
Beispiel #7
0
        public override void Render(System.Drawing.Graphics g, System.Drawing.Rectangle r)
        {
            base.Render(g, r);

            Font         nStrengthfont = new System.Drawing.Font(this.Font.Name, this.Font.Size, System.Drawing.FontStyle.Bold);
            StockProfile nStock        = (StockProfile)this.RowObject;

            if (nStock.LongStrength > nStock.ShortStrength)
            {
                g.DrawString(this.GetText(), nStrengthfont, System.Drawing.Brushes.Blue, r.Left + 20, r.Bottom, this.StringFormatForGdiPlus);
            }
            else
            {
                g.DrawString(this.GetText(), nStrengthfont, System.Drawing.Brushes.Red, r, this.StringFormatForGdiPlus);
            }
        }
Beispiel #8
0
        private bool QueryYahooFinanceProfile(ref StockProfile aStock)
        {
            String nYahooQueryStr = YahooFinanceParser.PROFILE_STR;

            nYahooQueryStr = nYahooQueryStr.Replace("@TICK", getYahooSymbol(aStock, aStock.Sym));

            String             nYahooHtmlStr = RESTController.GetREST(nYahooQueryStr);
            YahooFinanceParser nYahooParser  = new YahooFinanceParser(aStock);

            if (nYahooParser.StartHTML(nYahooHtmlStr))
            {
                return(true);
            }

            return(false);
        }
Beispiel #9
0
        private bool QueryMorningStar(ref StockProfile aStock)
        {
            String nMorningQueryStr = MorningStarParser.QUERY_STR;

            nMorningQueryStr = nMorningQueryStr.Replace("@TICK", getMorningStarSymbol(aStock, aStock.Sym));

            String            nMorningOutStr = RESTController.GetREST(nMorningQueryStr);
            MorningStarParser nMorningParser = new MorningStarParser(aStock);

            if (nMorningParser.StartCSV(nMorningOutStr))
            {
                return(true);
            }

            return(false);
        }
Beispiel #10
0
        private async Task <bool> QueryJitta(StockProfile aStock)
        {
            String nJittaQueryStr = JittaParser.QUERY_STR;

            nJittaQueryStr = nJittaQueryStr.Replace("@TICK", aStock.Sym).Replace("@MKT", aStock.Mkt);

            String nJittaOutStr = await HTTPController.GetREQUEST(nJittaQueryStr, API_KEY);

            JittaParser nJittaParser = new JittaParser(aStock);

            if (nJittaParser.StartJson(nJittaOutStr))
            {
                return(true);
            }

            return(false);
        }
Beispiel #11
0
 private void SearchOLV_Click(object sender, EventArgs e)
 {
     if (this.SearchOLV.SelectedItems.Count == 1)
     {
         Stock nStockObj = (Stock)this.SearchOLV.SelectedObject;
         this.SearchOLV.Hide();
         if (WatchlistController.getInstance().isExist(nStockObj.Sym))
         {
             this.StockQuery(WatchlistController.getInstance().GetStock(nStockObj.Sym), true);
         }
         else
         {
             StockProfile nStock = new StockProfile(nStockObj.Sym);
             nStock.Market = nStockObj.Market;
             this.StockQuery(nStock, true);
         }
     }
 }
Beispiel #12
0
 private void SearchOLV_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == Convert.ToChar(Keys.Return) && this.SearchOLV.SelectedItems.Count == 1)
     {
         Stock nStockObj = (Stock)this.SearchOLV.SelectedObject;
         this.SearchOLV.Hide();
         if (WatchlistController.getInstance().isExist(nStockObj.Sym))
         {
             this.StockQuery(WatchlistController.getInstance().GetStock(nStockObj.Sym), true);
         }
         else
         {
             StockProfile nStock = new StockProfile(nStockObj.Sym);
             nStock.Market = nStockObj.Market;
             this.StockQuery(nStock, true);
         }
     }
 }
Beispiel #13
0
        private void chartButton_Click(object sender, EventArgs e)
        {
            //MessageBox.Show( "Chart Not Available for this version!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation );
            if (watchlistOLV.SelectedItems.Count == 1)
            {
                StockProfile nStock     = (StockProfile)watchlistOLV.SelectedObject;
                StockData    nStockData = new StockData();
                nStockData.Name   = nStock.Name;
                nStockData.Sym    = nStock.Sym;
                nStockData.Mkt    = nStock.Mkt;
                nStockData.Market = nStock.Market;
                this.StockDownload(ref nStockData);

                if (nStockData.DataPoints.Count > 0)
                {
                    ChartingForm nForm = new ChartingForm(nStockData);
                    nForm.Show();
                }
            }
        }
Beispiel #14
0
        private async void StockQuery(StockProfile aStock, Boolean Editable = false, Boolean Save = false)
        {
            QueryController nController = new QueryController();
            bool            nResult     = await nController.QueryStock(aStock);

            if (!nResult)
            {
                return;
            }

            StockData nStockData = new StockData();

            nStockData.Name   = aStock.Name;
            nStockData.Sym    = aStock.Sym;
            nStockData.Mkt    = aStock.Mkt;
            nStockData.Market = aStock.Market;
            nResult           = nController.QueryStockData(ref nStockData);

            TAController nTACont = new TAController(nStockData);

            nTACont.Compute();

            aStock.ShortStrength  = nTACont.BearStrength;
            aStock.LongStrength   = nTACont.BullStrength;
            aStock.BullIndicators = nTACont.UptrendDescriptions;
            aStock.BearIndicators = nTACont.DowntrendDescriptions;

            if (Editable)
            {
                StockProfilingForm nForm = new StockProfilingForm(aStock);
                nForm.Show();
            }

            if (Save)
            {
                WatchlistController.getInstance().Add(aStock);
            }
        }
Beispiel #15
0
 public void Delete(StockProfile aStock)
 {
     this.StockModel.Remove(aStock);
 }
Beispiel #16
0
 public void Edit(StockProfile aStock)
 {
     this.StockModel.Edit(aStock);
 }
Beispiel #17
0
 public JittaParser(StockProfile aStock)
 {
     this.mStock = aStock;
 }
Beispiel #18
0
 public ReutersParser(StockProfile aStock)
 {
     this.mStock = aStock;
 }
Beispiel #19
0
 public MorningStarParser(StockProfile aStock)
 {
     this.mStock        = aStock;
     this.mCurrencyRate = 1;
     this.mCfg          = ConfigManager.getInstance().Config;
 }
Beispiel #20
0
 public StockProfilingForm(StockProfile aStock)
 {
     this.mStock = aStock;
     InitializeComponent();
     this.populateValues();
 }
Beispiel #21
0
 public YahooFinanceParser(StockProfile aStock)
 {
     this.mStock = aStock;
 }
Beispiel #22
0
        //http://f10.eastmoney.com/f10_v2/CompanySurvey.aspx?code=sz000002
        /// <summary>
        /// 获取股票基本信息数据
        /// </summary>
        /// <param name="stockCode">参数例子:sz000002</param>
        /// <returns>有返回IStockProfile对象,没有返回null</returns>
        public IStockProfile GetStockProfile(string stockCode)
        {
            string url = string.Format(@"http://f10.eastmoney.com/f10_v2/CompanySurvey.aspx?code={0}", FullStockCode.GetByCode(stockCode));

            string html = PageReader.GetPageSource(url, Encoding.UTF8);
            if (string.IsNullOrEmpty(html))
                return null;

            var htmlDocument = new HtmlDocument();
            htmlDocument.LoadHtml(html);
            var htmlNodes = htmlDocument.DocumentNode;

            StockProfile stockProfile = new StockProfile();
            /// 公司名称
            stockProfile.FullName = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[1]/td[1]").InnerText;
            /// 公司英文名称
            stockProfile.EnglishName = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[2]/td[1]").InnerText;
            /// 曾用名
            stockProfile.NameUsedBefore = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[3]/td[1]").InnerText;
            /// A股交易代码
            stockProfile.CodeA = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[4]/td[1]").InnerText;
            /// A股证券简称
            stockProfile.ShortNameA = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[4]/td[2]").InnerText;
            /// B股交易代码
            stockProfile.CodeB = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[5]/td[1]").InnerText;
            /// B股证券简称
            stockProfile.ShortNameB = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[5]/td[2]").InnerText;
            /// H股交易代码
            stockProfile.CodeH = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[6]/td[1]").InnerText;
            //H股简称
            stockProfile.ShortNameH = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[6]/td[2]").InnerText;

            /// 证券交易所//证券类别
            stockProfile.Exchange = DataConverter.GetMarketByString(htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[7]/td[1]").InnerText);
            /// 所属行业
            stockProfile.Industry = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[7]/td[2]").InnerText;
            /// 总经理
            stockProfile.GeneralManager = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[8]/td[1]").InnerText;
            /// 法人代表
            stockProfile.LegalRepresentative = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[8]/td[2]").InnerText;
            /// 董秘
            stockProfile.BoardSecretary = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[9]/td[1]").InnerText;
            /// 董事长
            stockProfile.Chairman = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[9]/td[2]").InnerText;
            /// 证券事务代表
            stockProfile.SecuritiesAffairsRepresentatives = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[10]/td[1]").InnerText;
            /// 独立董事
            stockProfile.IndependentDirectors = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[10]/td[2]").InnerText;
            /// 联系电话
            stockProfile.ContactNumber = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[11]/td[1]").InnerText;
            /// 电子信箱
            stockProfile.Email = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[11]/td[2]").InnerText;
            /// 传真
            stockProfile.Fax = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[12]/td[1]").InnerText;
            /// 公司网址
            stockProfile.Website = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[12]/td[2]").InnerText;
            /// 办公地址
            stockProfile.OfficeAddress = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[13]/td[1]").InnerText;
            /// 注册地址
            stockProfile.RegisteredAddress = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[13]/td[2]").InnerText;
            /// 区域
            stockProfile.Area = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[14]/td[1]").InnerText;
            /// 邮政编码
            stockProfile.ZipCode = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[14]/td[2]").InnerText;
            /// 注册资本(元)
            //decimal RegisteredCapital = decimal.Zero;
            //if (decimal.TryParse(htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[15]/td[1]").InnerText, out RegisteredCapital))
            //    stockProfile.RegisteredCapital = RegisteredCapital;
            stockProfile.RegisteredCapital = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[15]/td[1]").InnerText;
            /// 工商登记
            stockProfile.BusinessRegistration = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[15]/td[2]").InnerText;
            /// 雇员人数
            int NumberOfEmployees = 0;
            if (int.TryParse(htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[16]/td[1]").InnerText, out NumberOfEmployees))
                stockProfile.NumberOfEmployees = NumberOfEmployees;
            /// 管理人员人数
            int NumberOfManagement = 0;
            if (int.TryParse(htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[16]/td[2]").InnerText, out NumberOfManagement))
                stockProfile.NumberOfManagement = NumberOfManagement;
            /// 律师事务所
            stockProfile.LawOffice = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[17]/td[1]").InnerText;
            /// 会计师事务所
            stockProfile.AccountingFirm = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[17]/td[2]").InnerText;
            /// 公司简介
            stockProfile.CompanyProfile = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[18]/td[1]").InnerText;
            /// 主营业务范围
            stockProfile.PrimeBusiness = htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[12]/div[2]/table[1]/tr[19]/td[1]").InnerText;
            /// 成立日期
            DateTime EstablishmentDate = DateTime.MaxValue;
            if (DateTime.TryParse(htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[13]/div[2]/table[1]/tr[1]/td[1]").InnerText, out EstablishmentDate))
                stockProfile.EstablishmentDate = EstablishmentDate;
            /// 上市日期
            DateTime ListDate = DateTime.MaxValue;
            if (DateTime.TryParse(htmlNodes.SelectSingleNode("/html[1]/body[1]/div[1]/div[13]/div[2]/table[1]/tr[1]/td[2]").InnerText, out ListDate))
                stockProfile.ListDate = ListDate;

            return stockProfile;
        }