Ejemplo n.º 1
0
        public static DateTime?GetLastTradeDate()
        {
            DateTime start = DateTime.Today.AddDays(-30);
            DateTime end   = DateTime.Today;
            string   csv   = WebGet(
                string.Format(_EOD_URL_FMT,
                              HttpUtility.UrlEncode(_INDEX_SYMBOL_FOR_LAST_TRADE),
                              (start.Month - 1).ToString("00"),
                              start.Day,
                              start.Year,
                              (end.Month - 1).ToString("00"),
                              end.Day,
                              end.Year));

            if (string.IsNullOrEmpty(csv))
            {
                return(null);
            }
            string[] lines =
                csv.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
            List <Eod> indexEodLast30Days =
                lines.Select(l => InternetParser.ParseEod(l, _INDEX_SYMBOL_FOR_LAST_TRADE)).Where(e => e != null).ToList();

            return(indexEodLast30Days.Max(e => e.Date));
        }
Ejemplo n.º 2
0
        public static List <Company> ReadCompaniesByExchange(string exchange)
        {
            string csv = WebGet(
                string.Format(_COMPANY_URL_FMT, exchange));

            string[] lines =
                csv.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            return(lines.Select(l => InternetParser.ParseCompany(l, exchange)).Where(c => c != null).ToList());
        }
Ejemplo n.º 3
0
        public static List <Eod> ReadEodBySymbol(EodParam param)
        {
            if (param.Start >= param.End)
            {
                return(new List <Eod>());
            }
            string csv = WebGet(
                string.Format(_EOD_URL_FMT,
                              HttpUtility.UrlEncode(param.Symbol),
                              (param.Start.Month - 1).ToString("00"),
                              param.Start.Day,
                              param.Start.Year,
                              (param.End.Month - 1).ToString("00"),
                              param.End.Day,
                              param.End.Year));

            string[] lines =
                csv.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
            return(lines
                   .Select(l => InternetParser.ParseEod(l, param.Symbol))
                   .Where(e => (e != null && e.Date != param.Start)).ToList());
        }