コード例 #1
0
        public List <IFutureData> GatherFutureFundamentals(string month, bool showErrors)
        {
            var fundamentals = new FundamentalRepository();

            string[] fileArray = Directory.GetFiles(@"..\..\..\Files\FutureFundamentals\", $"{month}.csv", SearchOption.AllDirectories); //gets months fundamentals

            if (fileArray.Length != 0)
            {
                return(RetrieveFutureFundamentals(month));
            }
            else
            {
                stockCount = _fundList.Count();
                fundCount  = 0;

                foreach (var stock in _fundList)
                {
                    stock.Price  = fundamentals.GetPrice(stock.Symbol, month, showErrors);
                    stock.ADX    = Math.Round(fundamentals.GetADX(stock.Symbol, month, showErrors), 4);
                    stock.BBANDS = Math.Round(fundamentals.GetBBANDS(stock.Symbol, month, stock.Price, showErrors), 4);
                    stock.BOP    = Math.Round(fundamentals.GetBOP(stock.Symbol, month, showErrors), 4);
                    stock.MACD   = Math.Round(fundamentals.GetMACD(stock.Symbol, month, showErrors), 4);
                    stock.MOM    = Math.Round(fundamentals.GetMOM(stock.Symbol, month, stock.Price, showErrors), 4);
                    stock.RSI    = Math.Round(fundamentals.GetRSI(stock.Symbol, month, showErrors), 4);
                    fundCount++;
                }

                ClearEmptyStockData(ref _stockData);
                ClearEmptyFutureData(ref _fundList);

                fundamentals.SaveFutureFundamentals(_fundList, month);

                return(_fundList);
            }
        }
コード例 #2
0
        public List <IStockData> GatherFundamentals(string month, bool showErrors)
        {
            var fundamentals = new FundamentalRepository();
            var fundList     = new List <IFundamental>();

            string[] fileArray = Directory.GetFiles(@"..\..\..\Files\Fundamentals", $"{month}.csv", SearchOption.AllDirectories); //gets months fundamentals

            if (fileArray.Length != 0)
            {
                return(RetrieveFundamentals(month));
            }
            else
            {
                var stockData = _stockData;
                stockCount = stockData.Count();

                foreach (var stock in stockData)
                {
                    fundCount = fundList.Count();
                    var price = Math.Round(fundamentals.GetPrice(stock.Symbol, month, showErrors), 4);
                    stock.ADX    = Math.Round(fundamentals.GetADX(stock.Symbol, month, showErrors), 4);
                    stock.BBANDS = Math.Round(fundamentals.GetBBANDS(stock.Symbol, month, price, showErrors), 4);
                    stock.BOP    = Math.Round(fundamentals.GetBOP(stock.Symbol, month, showErrors), 4);
                    stock.MACD   = Math.Round(fundamentals.GetMACD(stock.Symbol, month, showErrors), 4);
                    stock.MOM    = Math.Round(fundamentals.GetMOM(stock.Symbol, month, price, showErrors), 4);
                    stock.RSI    = Math.Round(fundamentals.GetRSI(stock.Symbol, month, showErrors), 4);
                    stock.Gain   = Math.Round(fundamentals.GetGain(stock.Symbol, month, showErrors), 4);

                    fundList.Add(new Fundamental()
                    {
                        Symbol = stock.Symbol,
                        ADX    = stock.ADX,
                        BBANDS = stock.BBANDS,
                        BOP    = stock.BOP,
                        MACD   = stock.MACD,
                        MOM    = stock.MOM,
                        RSI    = stock.RSI,
                        Gain   = stock.Gain
                    });
                }

                ClearEmptyStockData(ref _stockData);
                ClearEmptyFundData(ref fundList);

                fundamentals.SaveFundamentals(fundList, month);

                return(_stockData);
            }
        }