Esempio n. 1
0
        /// <summary>Gets the min and max values from the MBMStockEntries.txt file</summary>
        /// <exception cref="Exception">Thrown when failed to retrieve min and max values from a file</exception>
        public Filter GetMinMaxValues()
        {
            try
            {
                Filter             filter       = new Filter();
                List <StockEntry>  stockEntries = new List <StockEntry>();
                CSVStockRepository stockRepo    = new CSVStockRepository(FilePath);

                stockEntries = stockRepo.GetStockEntries() as List <StockEntry>;

                filter.HighMin.Amount          = stockEntries.Min(y => y.PriceHigh.Amount);
                filter.HighMax.Amount          = stockEntries.Max(y => y.PriceHigh.Amount);
                filter.LowMin.Amount           = stockEntries.Min(y => y.PriceLow.Amount);
                filter.LowMax.Amount           = stockEntries.Max(y => y.PriceLow.Amount);
                filter.OpenMin.Amount          = stockEntries.Min(y => y.PriceOpen.Amount);
                filter.OpenMax.Amount          = stockEntries.Max(y => y.PriceOpen.Amount);
                filter.CloseMin.Amount         = stockEntries.Min(y => y.PriceClose.Amount);
                filter.CloseMax.Amount         = stockEntries.Max(y => y.PriceClose.Amount);
                filter.CloseAdjustedMin.Amount = stockEntries.Min(y => y.PriceCloseAdjusted.Amount);
                filter.CloseAdjustedMax.Amount = stockEntries.Max(y => y.PriceCloseAdjusted.Amount);

                filter.DateStart = stockEntries.Min(y => y.Date);
                filter.DateEnd   = stockEntries.Max(y => y.Date);
                filter.VolumeMin = stockEntries.Min(y => y.Volume);
                filter.VolumeMax = stockEntries.Max(y => y.Volume);

                return(filter);
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to retrieve min and max values from local file", ex);
            }
        }
Esempio n. 2
0
        /// <summary>Gets the list of symbols from the MBMStockEntries.txt file</summary>
        /// <exception cref="Exception">Thrown when failed to retrieve symbols from a file</exception>
        public IEnumerable <string> GetSymbols()
        {
            try
            {
                List <StockEntry>  stockEntries  = new List <StockEntry>();
                CSVStockRepository stockRepo     = new CSVStockRepository(FilePath);
                List <string>      uniqueSymbols = new List <string>();

                stockEntries = stockRepo.GetStockEntries() as List <StockEntry>;

                uniqueSymbols = stockEntries
                                .Select(s => s.Symbol)
                                .Distinct().ToList();

                uniqueSymbols.Add("all symbols");

                return(uniqueSymbols);
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to retrieve symbols from local file", ex);
            }
        }
Esempio n. 3
0
        /// <summary>Returns a stock repository. Values "WCF", "SQL", "CSV"</summary>
        public static IStockRepository GetRepository(string repositoryType)
        {
            IStockRepository repo = null;

            switch (repositoryType)
            {
            case "WCF":
                repo = new WCFStockRepository();
                break;

            case "SQL":
                repo = new SQLStockRepository();
                break;

            case "CSV":
                repo = new CSVStockRepository();
                break;

            default:
                throw new ArgumentException("Invalid repository type");
            }

            return(repo);
        }