public void PriceAverageTest()
 {
     for (int i = 0; i <= 9; i++)
     {
         Assert.AreNotEqual
             (-1, query.PriceAverage(start, end, i), "the " + i + " commodiry didnt have avarge");
     }
 }
Example #2
0
        public bool conditionIsMet(AlgoProcess process)
        {
            //Return true if the short-moving-average < mid-moving-average < long-moving-average
            DateTime minTimeRange = DateTime.Now.AddHours(-minTime);
            float    minAverage   = sql.PriceAverage(minTimeRange, DateTime.Now, process.commodity);

            DateTime medTimeRange = DateTime.Now.AddHours(-medTime);
            float    medAverage   = sql.PriceAverage(medTimeRange, DateTime.Now, process.commodity);

            DateTime maxTimeRange = DateTime.Now.AddHours(-maxTime);
            float    maxAverage   = sql.PriceAverage(maxTimeRange, DateTime.Now, process.commodity);

            if (minAverage < 0 | medAverage < 0 | maxAverage < 0)
            {
                return(false);
            }

            return((minAverage <= medAverage) & (medAverage < maxAverage));
        }
Example #3
0
        public void TestSQLStuffMethod()
        {
            HistoryDalImplementation sql = new HistoryDalImplementation();

            int minTime = 9;
            int medTime = 10;
            int maxTime = 100;


            DateTime minTimeRange = DateTime.Now.AddHours(-minTime);
            float minAverage = sql.PriceAverage(minTimeRange, DateTime.Now, 0);

            DateTime medTimeRange = DateTime.Now.AddHours(-medTime);
            float medAverage = sql.PriceAverage(medTimeRange, DateTime.Now, 0);

            DateTime maxTimeRange = DateTime.Now.AddHours(-maxTime);
            float maxAverage = sql.PriceAverage(maxTimeRange, DateTime.Now, 0);

            Console.WriteLine(minAverage);
            Console.WriteLine(medAverage);
            Console.WriteLine(maxAverage);

        }
Example #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            foreach (var series in chart1.Series)
            {
                series.Points.Clear();
            }

            for (int i = 0; i < 10; i++)
            {
                if (checkBox1.Checked && historyAcc.PriceAverage(DateTime.Now.AddHours(-24), DateTime.Now, i) != -1)
                {
                    chart1.Series[graphsList[0]].Points.AddXY(i, historyAcc.PriceAverage(DateTime.Now.AddHours(-24), DateTime.Now, i));
                }
                if (checkBox2.Checked && historyAcc.numOfHighest(DateTime.Now.AddHours(-24), DateTime.Now, i) != -1)
                {
                    chart1.Series[graphsList[1]].Points.AddXY(i, historyAcc.numOfHighest(DateTime.Now.AddHours(-24), DateTime.Now, i));
                }
                if (checkBox3.Checked && historyAcc.numOfLowest(DateTime.Now.AddHours(-24), DateTime.Now, i) != -1)
                {
                    chart1.Series[graphsList[2]].Points.AddXY(i, historyAcc.numOfLowest(DateTime.Now.AddHours(-24), DateTime.Now, i));
                }
            }
            myLogger.Info("User generate graph");
        }