Exemplo n.º 1
0
        public async Task YahooQuotesDownloaderTest()
        {
            var setting = new YahooQuotesSetting();

            setting.Properties = new QuoteProperty[] {
                QuoteProperty.LastTradePriceOnly,
                QuoteProperty.ChangeInPercent,
                QuoteProperty.OneyrTargetPrice,
                QuoteProperty.PercentChangeFromFiftydayMovingAverage,
                QuoteProperty.PercentChangeFromTwoHundreddayMovingAverage
            };

            setting.IDs = new string[] { "^TNX" };//MyHelper.GetStringToken(tickers, new string[] { ";", "," });
            var downloader = new YahooQuotesDownloader(setting);
            var result     = await downloader.DownloadObjectTaskAsync().ConfigureAwait(false);


            result.SortBy(QuoteProperty.PercentChangeFromTwoHundreddayMovingAverage);
            foreach (var item in result.Items)
            {
                Debug.WriteLine(string.Format("{0}     {1}               {2}           {3}          {4}          {5}         {6}",
                                              item.ID.PadRight(5),
                                              item.Name.PadLeft(17),
                                              item.LastTradePriceOnly.ToString().PadLeft(9),
                                              item.ChangeInPercent.ToString().PadLeft(9),
                                              (item[QuoteProperty.OneyrTargetPrice] ?? 0).ToString().PadLeft(8),
                                              (item[QuoteProperty.PercentChangeFromFiftydayMovingAverage] ?? 0).ToString().PadLeft(8),
                                              (item[QuoteProperty.PercentChangeFromTwoHundreddayMovingAverage] ?? 0).ToString().PadLeft(8)
                                              ));
            }
        }
Exemplo n.º 2
0
        public static async Task <double> GetRiskFreeRate()
        {
            var setting = new YahooQuotesSetting();

            setting.IDs = new string [] { "^TNX" };
            var downloader = new YahooQuotesDownloader(setting);
            var result     = await downloader.DownloadObjectTaskAsync().ConfigureAwait(false);

            return(result.Items[0].LastTradePriceOnly);
        }
Exemplo n.º 3
0
        public static async Task <YahooQuotesAggregate> GetQuote(string[] tickers, params QuoteProperty[] quoteProperties)
        {
            var setting = new YahooQuotesSetting();

            setting.IDs        = tickers;
            setting.Properties = quoteProperties;
            var downloader = new YahooQuotesDownloader(setting);
            var result     = await downloader.DownloadObjectTaskAsync().ConfigureAwait(false);

            return(result);
        }