public List <Quotation> GetQuotations(string companyTicket, TickPeriodType period, DateTime start, DateTime end) { List <CompanyInfo> companies = CompanyInfoBuilder.Instance.GetCompanyInfos(); CompanyInfo company = companies.FirstOrDefault(c => c.Ticket == companyTicket); if (null == company) { return(null); } ResponseData responseData = getResponseData(company.ISIN, start, end); List <Quotation> quotations = new List <Quotation>(); foreach (data d in responseData.data) { Quotation q = convertDataToQuotation(d); if (q.Open > 0) { quotations.Add(q); } } return(quotations); }
// 2014.12.10,06:15,1.23919,1.23934,1.23888,1.23913,570 public List <Quotation> GetQuotationFromMT4File(string filePath) { if (null == filePath) { return(new List <Quotation>()); } List <Quotation> collection = new List <Quotation>(); string[] lines = File.ReadAllLines(filePath); foreach (string line in lines) { if (string.IsNullOrEmpty(line)) { continue; } string[] items = line.Split(','); DateTime dateTime = getDateTimeFromItems(items[0], items[1]); //items = items.Select(i => i.Replace('.', ',')).ToArray(); double open = Convert.ToDouble(items[2]); double high = Convert.ToDouble(items[3]); double low = Convert.ToDouble(items[4]); double close = Convert.ToDouble(items[5]); int volume = Convert.ToInt32(items[6]); Quotation iQuotation = new Quotation { DateTime = dateTime, Open = open, Close = close, High = high, Low = low, Volume = volume }; collection.Add(iQuotation); } TickPeriodType tickPeriod = getTickTypeFromQuotations(collection[0], collection[1]); foreach (Quotation q in collection) { q.TypePeriod = tickPeriod; } return(collection); }