コード例 #1
0
 public decimal Value(Date date)
 {
     if (EffectivePeriod.Contains(date))
     {
         return(Properties[date].Units * Stock.GetPrice(date));
     }
     else
     {
         return(0.00m);
     }
 }
コード例 #2
0
        public void Change(Date date, int unitChange, decimal amountChange, decimal costBaseChange, IPortfolioTransaction transaction)
        {
            if (!EffectivePeriod.Contains(date))
            {
                throw new EffectiveDateException("The parcel is not effective at that date");
            }

            var parcelProperties = _Properties[date];

            var newUnits    = parcelProperties.Units + unitChange;
            var newAmount   = parcelProperties.Amount + amountChange;
            var newCostBase = parcelProperties.CostBase + costBaseChange;

            if (newUnits < 0)
            {
                throw new ArgumentException("Units cannot be changed to be less than 0");
            }
            if (newAmount < 0)
            {
                throw new ArgumentException("Amount cannot be changed to be less than 0");
            }
            if (newCostBase < 0)
            {
                throw new ArgumentException("Costbase cannot be changed to be less than 0");
            }

            ParcelProperties newParcelProperties;

            if (newUnits == 0)
            {
                End(date);
                newParcelProperties = new ParcelProperties(0, 0.00m, 0.00m);
            }
            else
            {
                newParcelProperties = new ParcelProperties(newUnits, newAmount, newCostBase);
            }

            _Properties.Change(date, newParcelProperties);

            _Audit.Add(new ParcelAudit(date, unitChange, costBaseChange, amountChange, transaction));
        }
コード例 #3
0
 public bool IsEffectiveAt(Date date)
 {
     return(EffectivePeriod.Contains(date));
 }