public void TestIfFoundAverageVolume()
        {
            #region arrange
            List <Financial_Instrument> fi  = new List <Financial_Instrument>();
            Financial_Instrument        fin = new Financial_Instrument();
            fin.Symbol = "SNP";
            fin.Volume = 500;
            fi.Add(fin);
            Financial_Instrument fin1 = new Financial_Instrument();
            fin1.Symbol = "SNP";
            fin1.Volume = 1000;
            fi.Add(fin1);

            Financial_Instrument fin2 = new Financial_Instrument();
            fin2.Symbol = "RRC";
            fin2.Volume = 1000;
            fi.Add(fin2);
            #endregion
            #region act
            Statistics a = new Statistics(fi);
            #endregion
            #region assert
            Assert.AreEqual(750, a.AverageVolume("SNP"));
            #endregion
        }
        public void TestISymbolNotFound()
        {
            #region arrange
            List <Financial_Instrument> fi  = new List <Financial_Instrument>();
            Financial_Instrument        fin = new Financial_Instrument();
            fin.Symbol = "TLV";
            fin.Price  = 20;
            fi.Add(fin);
            Financial_Instrument fin1 = new Financial_Instrument();
            fin1.Symbol = "TLV";
            fin1.Price  = 22;
            fi.Add(fin1);

            Financial_Instrument fin2 = new Financial_Instrument();
            fin2.Symbol = "ATLV";
            fin2.Price  = 22;
            fi.Add(fin2);

            #endregion
            #region act
            Statistics a = new Statistics(fi);
            #endregion
            #region assert
            Assert.AreEqual(null, a.AveragePrice("BCR"));
            #endregion
        }
        public void TestStdev()
        {
            #region arrange
            List <Financial_Instrument> fi = new List <Financial_Instrument>();
            FirmaTranzactionata         ft = new FirmaTranzactionata();
            ft.Symbol = "SNP";
            Financial_Instrument fin = new Financial_Instrument(ft);

            fin.Price = 5;
            fi.Add(fin);

            FirmaTranzactionata ft1 = new FirmaTranzactionata();
            ft1.Symbol = "SNP";

            Financial_Instrument fin1 = new Financial_Instrument(ft1);

            fin1.Price = 9;
            fi.Add(fin1);

            Financial_Instrument fin2 = new Financial_Instrument();
            fin2.Symbol = "RRC";
            fin2.Volume = 1000;
            fi.Add(fin2);
            #endregion
            #region act
            Statistics a = new Statistics(fi);
            #endregion
            #region assert
            Assert.AreEqual((decimal)2.83, Math.Round((decimal)a.StandardDev("SNP"), 2));  // desi valorile sunt egale, daca unul e tip decimal
            //si unul e double, nu le considera egale. De ce? Cum pot sa fac sa elimin nevoia asta de conversie?
            #endregion
        }
Exemple #4
0
        public static List <Financial_Instrument> IntroducereManuala()
        {
            List <Financial_Instrument> Assets = new List <Financial_Instrument>();

            for (int i = 0; i < 1000000; i++)
            {
                Financial_Instrument Asset = new Financial_Instrument();
                Console.WriteLine("Introduceti simbolul instrumentului:");
                Asset.Symbol = Console.ReadLine();
                Console.WriteLine("Introduceti pretul de inchidere al instrumentului:");
                Asset.Price = Decimal.Parse(Console.ReadLine());
                Console.WriteLine("Introduceti volumul de tranzactionare al instrumentului:");
                Asset.Volume = Int32.Parse(Console.ReadLine());
                Console.WriteLine(" Data curenta este" + DateTime.Now + ". Introduceti ziua tranzactionarii:");
                Asset.TransactionDate = DateTime.Parse(Console.ReadLine());
                Assets.Add(Asset);
                Console.WriteLine($"Pana acum, lista contine {Assets.Count} elemente");
                Console.WriteLine("Daca doriti sa introduceti un nou intrument, apasati 1:");
                if (Console.ReadLine() == "1")
                {
                    continue;
                }
                else
                {
                    break;
                }
            }
            Console.ReadLine();
            return(Assets);
        }
Exemple #5
0
        public static List <Financial_Instrument> CitireFisier()
        {
            string CurrFile = @"SourceFile.txt";

            string[] lines = File.ReadAllLines(CurrFile);
            List <Financial_Instrument> Assets = new List <Financial_Instrument>();
            int RecordsNumber = lines.Count();

            for (int i = 0; i < RecordsNumber; i++)
            {
                string[]             words = lines[i].Split(',');
                Financial_Instrument Asset = new Financial_Instrument
                {
                    Symbol          = words[0],
                    Price           = Decimal.Parse(words[1]),
                    Volume          = Int32.Parse(words[2]),
                    TransactionDate = DateTime.Parse(words[3])
                };
                Assets.Add(Asset);
            }
            var simboluri = Assets.Select(a => a.Symbol).Distinct().ToArray();

            foreach (var item in simboluri)
            {
                Console.WriteLine($"aici {item}");
            }

            Console.WriteLine($"Lista contine {Assets.Count} elemente");

            return(Assets);
        }
        public void TestDistinctSymbol2()
        {
            #region arrange
            List <Financial_Instrument> fi  = new List <Financial_Instrument>();
            Financial_Instrument        fin = new Financial_Instrument();
            fin.firma.Symbol = "SNP";
            fi.Add(fin);
            Financial_Instrument fin1 = new Financial_Instrument();
            fin1.Symbol = "SNP";
            fi.Add(fin1);

            #endregion
            #region act
            var simboluri = fi.Select(a => a.Symbol).Distinct().ToArray();
            #endregion
            #region assert
            Assert.AreEqual(1, simboluri.Length);
            #endregion
        }