Ejemplo n.º 1
0
        /// <summary>
        /// Конструктор преобразования MarketOrder в PositionItem
        /// </summary>
        public PositionItem(MarketOrder c)
        {
            foreach (var prop in c.GetType().GetProperties())
            {
                var prop2 = c.GetType().GetProperty(prop.Name);
                if (prop2.GetSetMethod() != null)
                {
                    prop2.SetValue(this, prop.GetValue(c, null), null);
                }
            }

            PriceEnter   = (decimal)c.PriceEnter;
            PriceExit    = (decimal?)c.PriceExit;
            ResultPoints = (decimal?)c.ResultPoints;
            ResultDepo   = (decimal?)c.ResultDepo;
        }
Ejemplo n.º 2
0
        public void EmptyEquitySeriesDoesNotCrash()
        {
            var equityPoints = new SortedList <DateTime, double>
            {
                { new DateTime(2019, 1, 3, 5, 0, 5), 100000 }
            };
            var series = new Series <DateTime, double>(equityPoints);
            var order  = new MarketOrder(Symbols.SPY, 1m, new DateTime(2019, 1, 3, 5, 0, 0));

            // Force an order ID >= 1 on the order, otherwise the test will fail
            // because the order will be filtered out.
            order.GetType().GetProperty("Id").SetValue(order, 1);

            var orders = new List <Order>
            {
                order
            };

            Assert.DoesNotThrow(() => PortfolioLooper.FromOrders(series, orders).ToList());
        }