public StockProperties ConvertCSV(string rowData) { string[] colData = rowData.Split(','); StockProperties StockToReturn = new StockProperties(); if (colData.Count() == 18) { StockToReturn.Name = colData[14].Trim(new char[] { '"' }) + colData[15].Trim(new char[] { '"' }); StockToReturn.TimeStamp = Convert.ToDecimal(colData[16]); StockToReturn.PullGroup = Convert.ToInt32(colData[17]); } else { StockToReturn.Name = colData[14].Trim(new char[] { '"' }); StockToReturn.TimeStamp = Convert.ToDecimal(colData[15]); StockToReturn.PullGroup = Convert.ToInt32(colData[16]); } StockToReturn.Symbol = colData[0].Trim(new char[] { '"' }); StockToReturn.PreviousClose = Convert.ToDecimal(colData[1]); StockToReturn.Open = Convert.ToDecimal(colData[2]); StockToReturn.PercentFromMoveAve = Convert.ToDecimal(colData[3]); StockToReturn.ChangeDaily = Convert.ToDecimal(colData[4]); StockToReturn.Ask = Convert.ToDecimal(colData[5]); StockToReturn.ShortRatio = Convert.ToDecimal(colData[6]); StockToReturn.PercentChangeDaily = Convert.ToDecimal(colData[7].Trim(new char[] { '%', '"' })); StockToReturn.PEGRatio = Convert.ToDecimal(colData[8]); StockToReturn.SharesOutstanding = Convert.ToDecimal(colData[9]); StockToReturn.PriceOverSales = Convert.ToDecimal(colData[10]); StockToReturn.PriceOverEPSCurrent = Convert.ToDecimal(colData[11]); StockToReturn.PriceOverEPSForecast = Convert.ToDecimal(colData[12]); StockToReturn.Volume = Convert.ToDecimal(colData[13]); return(StockToReturn); }
public List <List <StockProperties> > DatabaseGetter() { List <List <StockProperties> > HistoricData = new List <List <StockProperties> >(); List <StockProperties> StockValueAtInterval = new List <StockProperties>(); StockProperties NewStockToAdd = new StockProperties(); StockValueAtInterval.Clear(); StreamReader reader = new StreamReader(File.OpenRead(@"C: \Users\Derek Scheller\Documents\Visual Studio 2015\Projects\Stock Market Project\StockDataBase.csv")); string line = reader.ReadLine(); NewStockToAdd = ConvertCSV(line); StockValueAtInterval.Add(NewStockToAdd); int IntervalGroup = NewStockToAdd.PullGroup; while (!reader.EndOfStream) { line = reader.ReadLine(); NewStockToAdd = ConvertCSV(line); if (IntervalGroup == NewStockToAdd.PullGroup) { StockValueAtInterval.Add(NewStockToAdd); } else { HistoricData.Add(StockValueAtInterval); StockValueAtInterval = new List <StockProperties>(); StockValueAtInterval.Add(NewStockToAdd); IntervalGroup = NewStockToAdd.PullGroup; } } return(HistoricData); }
public int BuyLongVsShortDeterminent(StockProperties StockToCheck) { int LongShortConfidence = 0; if (StockToCheck.ShortRatio < 40) { LongShortConfidence += 1; } if (StockToCheck.ShortRatio > 50) { LongShortConfidence -= 2; } if (StockToCheck.PercentFromMoveAve > 0) { if (StockToCheck.PriceOverEPSCurrent < StockToCheck.PriceOverEPSForecast) { LongShortConfidence += 1; } LongShortConfidence += 1; } if (StockToCheck.PercentFromMoveAve > 5) { LongShortConfidence += 1; } if (StockToCheck.PercentFromMoveAve < -5) { LongShortConfidence -= 1; } if (StockToCheck.PriceOverSales > 1.5m) { LongShortConfidence -= 1; if (StockToCheck.PriceOverSales > 2) { LongShortConfidence -= 1; } } if (StockToCheck.PriceOverSales < 1.5m) { LongShortConfidence += 1; if (StockToCheck.PriceOverSales < 1) { LongShortConfidence += 1; if (StockToCheck.PriceOverSales < .5m) { LongShortConfidence += 1; } } } if (StockToCheck.PEGRatio < 1) { if (StockToCheck.Volume > 100000) { LongShortConfidence += 1; } LongShortConfidence += 1; } return(LongShortConfidence); }
public List <StockProperties> ConverterRawPull(string csvData) { List <StockProperties> stockListImport = new List <StockProperties>(); string[] rowData = csvData.Replace("\r", "").Split('\n'); foreach (string row in rowData) { if (string.IsNullOrEmpty(row)) { continue; } string[] colData = row.Split(','); StockProperties StockToReturn = new StockProperties(); if (colData.Count() == 16) { StockToReturn.Name = colData[14].Trim(new char[] { '"' }) + colData[15].Trim(new char[] { '"' }); } else { StockToReturn.Name = colData[14].Trim(new char[] { '"' }); } StockToReturn.Symbol = colData[0].Trim(new char[] { '"' }); StockToReturn.PreviousClose = Convert.ToDecimal(colData[1]); StockToReturn.Open = Convert.ToDecimal(colData[2]); StockToReturn.PercentFromMoveAve = Convert.ToDecimal(colData[3]); StockToReturn.ChangeDaily = Convert.ToDecimal(colData[4]); StockToReturn.Ask = Convert.ToDecimal(colData[5]); StockToReturn.ShortRatio = Convert.ToDecimal(colData[6]); StockToReturn.PercentChangeDaily = Convert.ToDecimal(colData[7].Trim(new char[] { '%', '"' })); StockToReturn.PEGRatio = Convert.ToDecimal(colData[8]); StockToReturn.SharesOutstanding = Convert.ToDecimal(colData[9]); StockToReturn.PriceOverSales = Convert.ToDecimal(colData[10]); StockToReturn.PriceOverEPSCurrent = Convert.ToDecimal(colData[11]); StockToReturn.PriceOverEPSForecast = Convert.ToDecimal(colData[12]); StockToReturn.Volume = Convert.ToDecimal(colData[13]); stockListImport.Add(StockToReturn); } return(stockListImport); }