Example #1
0
        public void Week1_Task1()
        {
            var nameList = "Davis, Clyne, Fonte, Hooiveld, Shaw, Davis, Schneiderlin, Cork, Lallana, Rodriguez, Lambert";

            var expected = "1. Davis, 2. Clyne, 3. Fonte, 4. Hooiveld, 5. Shaw, 6. Davis, 7. Schneiderlin, 8. Cork, 9. Lallana, 10. Rodriguez, 11. Lambert";

            var result = Week1.Task1(nameList, ',');

            result.ShouldBe(expected);
        }
Example #2
0
        public void All_solutions_same()
        {
            var logins      = PasscodeDerivation.KeyLog.Lines();
            var edSolution  = PasscodeDerivation.ShortestPhrase(logins).ToString();
            var kevSolution = Week1.Computeaverage(logins);
            var leeSolution = LeeSolution.Compute(logins);

            Assert.AreEqual(edSolution, kevSolution);
            Assert.AreEqual(edSolution, leeSolution);
        }
Example #3
0
 public void TimeIdentifiersAreAlikeWhenTheyAreEqual()
 {
     Assert.True(AcademicYear.IsAlike(AcademicYear));
     Assert.True(CalendarYear.IsAlike(CalendarYear));
     Assert.True(FinancialYear.IsAlike(FinancialYear));
     Assert.True(TaxYear.IsAlike(TaxYear));
     Assert.True(AcademicYearQ1.IsAlike(AcademicYearQ1));
     Assert.True(CalendarYearQ1.IsAlike(CalendarYearQ1));
     Assert.True(FinancialYearQ1.IsAlike(FinancialYearQ1));
     Assert.True(TaxYearQ1.IsAlike(TaxYearQ1));
     Assert.True(January.IsAlike(January));
     Assert.True(SpringTerm.IsAlike(SpringTerm));
     Assert.True(ReportingYear.IsAlike(ReportingYear));
     Assert.True(Week1.IsAlike(Week1));
     Assert.True(FinancialYearPart1.IsAlike(FinancialYearPart1));
 }
Example #4
0
        public void Kev_speed_of_alogithm()
        {
            var logins = PasscodeDerivation.KeyLog.Lines();

            StatsCollection result = LinqPadUX.Measure.Action(() => Week1.Computeaverage(logins));

            var builder = new StringBuilder();

            result.WriteReportTable(new StringWriter(builder), 1f);

            var temporaryFile = FileUtility.GetTemporaryFile(".html");

            File.WriteAllText(temporaryFile, builder.ToString());
            System.Diagnostics.Process.Start(temporaryFile);
            //File.Delete(temporaryFile);
        }
        public void StepSecond()
        {
            if (Second1.FutureCount == 0)
            {
                throw new Exception("No future to step to");
            }
            PriceCandle candle = Second1.GetFuture(0);

            // Close orders
            List <TradingOrder> ClosingOrders = CheckOrderLimits(OpenOrders, candle);

            foreach (TradingOrder closed_order in ClosingOrders)
            {
                this.OpenOrders.Remove(closed_order.OrderTicket);
                this.ClosedOrders.Add(closed_order);
                this.Cash += closed_order.Profit;
            }

            // Compute equity
            this.Equity = Cash;
            foreach (TradingOrder open_order in OpenOrders.Values)
            {
                Equity += open_order.ComputeValue(Prices.GetHistory(0));
            }


            Prices.Step();
            Second1.Step();
            if ((0 < Minute1.FutureCount) && (Prices.GetHistory(0).Time == Minute1.GetFuture(0).CloseTime))
            {
                Minute1.Step();
            }
            else
            {
                // if it is not the end of a minute the others also do not nee to step
                return;
            }

            if ((0 < Minute15.FutureCount) && (Prices.GetHistory(0).Time == Minute15.GetFuture(0).CloseTime))
            {
                Minute15.Step();
            }

            if ((0 < Minute30.FutureCount) && (Prices.GetHistory(0).Time == Minute30.GetFuture(0).CloseTime))
            {
                Minute30.Step();
            }

            if ((0 < Hour1.FutureCount) && (Prices.GetHistory(0).Time == Hour1.GetFuture(0).CloseTime))
            {
                Hour1.Step();
            }

            if ((0 < Hour4.FutureCount) && (Prices.GetHistory(0).Time == Hour4.GetFuture(0).CloseTime))
            {
                Hour4.Step();
            }

            if ((0 < Day1.FutureCount) && (Prices.GetHistory(0).Time == Day1.GetFuture(0).CloseTime))
            {
                Day1.Step();
            }

            if ((0 < Week1.FutureCount) && (Prices.GetHistory(0).Time == Week1.GetFuture(0).CloseTime))
            {
                Week1.Step();
            }

            if ((0 < Month1.FutureCount) && (Prices.GetHistory(0).Time == Month1.GetFuture(0).CloseTime))
            {
                Month1.Step();
            }
        }
Example #6
0
 public Week1Tests()
 {
     _week1 = new Week1();
 }
Example #7
0
 public void GetAssociatedRangeForWeeksReturnsAssociatedRange()
 {
     Assert.Equal(TimeIdentifierUtil.GetWeeks(), Week1.GetAssociatedRange());
 }
Example #8
0
 public Week1Tests()
 {
     lesson1 = new Week1();
     rand    = new Random();
 }