//public List<ForexPriceRecord> Read(DateTime priceDate) //{ // return Read(Path.Combine(FileDataPath, Forexite.DateToFileName1(priceDate)), PredicateBuilder.True<ForexPriceRecord>()); //} //public List<ForexPriceRecord> Read(string zipFilePath) //{ // return Read(zipFilePath, PredicateBuilder.True<ForexPriceRecord>()); //} public List <ForexPriceRecord> Read(string zipFilePath) { // file must exist if (!File.Exists(zipFilePath)) { throw new FileNotFoundException(); } List <ForexPriceRecord> priceRecs = new List <ForexPriceRecord>(); byte[] block = ZippedFile.ZipDataStreamBytes(zipFilePath); if (block.Length > 0) { priceRecs.AddRange((from f in (from f in System.Text.Encoding.Default.GetString(block, 0, block.Length).Split('\r').ToList() where !f.StartsWith("<") && f.Length > 6 select f.Replace("\n", "")).ToArray() let rec = f.Split(',') select new ForexPriceRecord() { Symbol = rec[0], PriceDateTime = Forexite.ParseDate(rec[1], rec[2]), Open = double.Parse(rec[3]), High = double.Parse(rec[4]), Low = double.Parse(rec[5]), Close = double.Parse(rec[6]), }) .ToList()); } return(priceRecs); }
public List <ForexitePriceRecord> Read(string zipFilePath, Expression <Func <ForexitePriceRecord, bool> > pred) { List <ForexitePriceRecord> priceRecs = new List <ForexitePriceRecord>(); byte[] block = ZippedFile.ZipDataStreamBytes(zipFilePath); if (block.Length > 0) { priceRecs.AddRange((from f in (from f in System.Text.Encoding.Default.GetString(block, 0, block.Length).Split('\r').ToList() where !f.StartsWith("<") && f.Length > 6 select f.Replace("\n", "")).ToArray() let rec = f.Split(',') select new ForexitePriceRecord() { Symbol = rec[0], PriceDateTime = Forexite.ParseDate(rec[1], rec[2]), Open = double.Parse(rec[3]), High = double.Parse(rec[4]), Low = double.Parse(rec[5]), Close = double.Parse(rec[6]), }) .ToList().Where(pred.Compile())); } return(priceRecs); }
public List <string> ToCsvList(string zipFilePath) { byte[] block = ZippedFile.ZipDataStreamBytes(zipFilePath); List <string> recs = System.Text.Encoding.Default.GetString(block, 0, block.Length).Split('\r').ToList(); return((from r in recs where !r.StartsWith("<") && r.Length > 6 select r.Replace("\n", "")).ToList()); }
public byte[] ToByteArray(string zipFilePath) { return(ZippedFile.ZipDataStreamBytes(zipFilePath)); }
public string ToCsvString(string zipFilePath) { byte[] block = ZippedFile.ZipDataStreamBytes(zipFilePath); return(System.Text.Encoding.Default.GetString(block, 0, block.Length)); }