Пример #1
0
        public void AverageReturnFrom_ReturnsAverage()
        {
            var returns = new Returns();

            var emptyBoard = Board.CreateEmptyBoard();
            var action     = new TicTacToeAction();

            returns.Add(emptyBoard, action, 2);
            returns.Add(emptyBoard, action, 4);

            Assert.AreEqual(3, returns.AverageReturnFrom(emptyBoard, action));
        }
Пример #2
0
        /// <summary>
        /// Ends the execution of the current method.
        ///
        /// If the current method does not return void, pops a value from the stack and returns it to the calling method.
        ///
        /// Return should leave the stack empty.
        /// </summary>
        public Emit <DelegateType> Return()
        {
            if (ReturnType == TypeOnStack.Get(typeof(void)))
            {
                UpdateState(Wrap(new[] { new StackTransition(0) }, "Return"));

                UpdateState(OpCodes.Ret, Wrap(StackTransition.None(), "Return"));

                Returns.Add(IL.Index);
                MustMark = true;

                return(this);
            }

            UpdateState(OpCodes.Ret, Wrap(StackTransition.Pop(ReturnType), "Return"));

            Returns.Add(IL.Index);

            UpdateState(Wrap(new[] { new StackTransition(0) }, "Return"));
            MustMark = true;

            var verify = CurrentVerifiers.Return();

            if (!verify.Success)
            {
                throw new SigilVerificationException("Return", verify, IL.Instructions(AllLocals));
            }

            return(this);
        }
Пример #3
0
        protected virtual void FillReturns(ColumnInfo column)
        {
            if (!_processedColumns.ContainsKey(column.Table))
            {
                _processedColumns.Add(column.Table, new List <string> ( ));

                FillReturns(column.Table.KeyColumn);

                if (null != column.Table.ForeignColumn)
                {
                    FillReturns(column.Table.ForeignColumn);
                }
            }


            if (!_processedColumns[column.Table].Contains(column.Name))
            {
                //always return any matching
                Returns.Add(string.Format(SqlQueries.Table_Column_Formatted, column.Table.Name, column.Name));

                _processedColumns[column.Table].Add(column.Name);

                ColumnDefenitions.Add(column.Defenition);
            }
        }
Пример #4
0
            public Node(IEnumerable <string> contents)
            {
                NodeId = int.Parse(contents.First().Substring(12, 2));
                foreach (string str in contents)
                {
                    bool skip = false;
                    foreach (string check in Blacklist)
                    {
                        if (str.Contains(check))
                        {
                            skip = true;
                        }
                    }
                    if (skip)
                    {
                        continue;
                    }

                    Body.Add(str);
                    if (str.Contains("return"))
                    {
                        Returns.Add(int.Parse(str.Split('n')[1].Split(';')[0]));
                    }
                }
                Body.Add("}");
            }
Пример #5
0
        public void AddValue(double value, DateTime?dt = null)
        {
            if (Equity.Count == 0)
            {
                Returns.Add(0);
                Changes.Add(0);
            }
            else
            {
                Returns.Add(Equity.Last() != 0 ? value / Equity.Last() - 1 : 0);
                Changes.Add(value - Equity[Equity.Count - 1]);
            }

            Equity.Add(value);
            _maxEquity = Math.Max(_maxEquity, value);
            DrawdownPct.Add(_maxEquity == 0 ? 0 : value / _maxEquity - 1);
            DrawdownAmt.Add(Equity.Last() - _maxEquity);

            if (dt != null)
            {
                AddDrawdownLengths(dt.Value);
            }

            Dates.Add(dt);
        }
Пример #6
0
        public void AddChange(double change, DateTime?dt = null)
        {
            if (Equity.Count == 0)
            {
                Returns.Add(0);
                Equity.Add(change);
            }
            else
            {
                Returns.Add(Equity.Last() != 0 ? change / Equity.Last() : 0);
                Equity.Add(Equity[Equity.Count - 1] + change);
            }

            Changes.Add(change);
            _maxEquity = Math.Max(_maxEquity, Equity.Last());
            DrawdownPct.Add(_maxEquity == 0 ? 0 : Equity.Last() / _maxEquity - 1);
            DrawdownAmt.Add(Equity.Last() - _maxEquity);

            if (dt != null)
            {
                AddDrawdownLengths(dt.Value);
            }

            Dates.Add(dt);
        }
Пример #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ret">Net Return</param>
        public void AddReturn(double ret, DateTime?dt = null)
        {
            if (Equity.Count == 0)
            {
                Equity.Add(1);
                Changes.Add(0);
            }
            else
            {
                Equity.Add(Equity.Last() * (1 + ret));
                Changes.Add(Equity[Equity.Count - 1] - Equity[Equity.Count - 2]);
            }

            _maxEquity = Math.Max(_maxEquity, Equity.Last());
            Returns.Add(ret);
            DrawdownPct.Add(_maxEquity == 0 ? 0 : Equity.Last() / _maxEquity - 1);
            DrawdownAmt.Add(Equity.Last() - _maxEquity);

            if (dt != null)
            {
                AddDrawdownLengths(dt.Value);
            }

            Dates.Add(dt);
        }