Example #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="dividendDetails">The details of the cash dividend (date, price)</param>
        /// <param name="units">The total number of units over which dividend is paid</param>
        public CashDividend(IAccountTypeCustomer account, IMemorialBooking journalEntry, string description, decimal taxPercentage, IDividendHistory dividendDetails, InstrumentSize units, IGLLookupRecords lookups)
            : base(account, journalEntry, description, taxPercentage)
        {
            if (dividendDetails == null)
                throw new ApplicationException("Dividend details are mandatory.");

            if (units == null || units.IsZero)
                throw new ApplicationException("The number of units is mandatory.");

            this.DividendDetails = dividendDetails;
            this.UnitsInPossession = units;
            //this.CashGeneratingInstrument = dividendDetails.Instrument;

            createComponents(lookups);
        }
        public CorporateActionStockDividend(IAccountTypeInternal acctA, IAccount acctB,
        InstrumentSize valueSize, Price price, decimal exRate, DateTime transactionDate,
        IDividendHistory dividendDetails, InstrumentSize previousSize,
        ITradingJournalEntry tradingJournalEntry)
            : base(acctA, acctB, valueSize,
                 price, exRate, transactionDate, transactionDate,
                 0M, valueSize.Sign ? Side.XI : Side.XO,
                 tradingJournalEntry, null, null)
        {
            if (dividendDetails == null)
                throw new ApplicationException("Dividend details are mandatory when creating a stock dividend corporate action");

            if (previousSize == null)
                throw new ApplicationException("The units in possession are mandatory when creating a stock dividend corporate action");
            else if (previousSize.IsZero)
                throw new ApplicationException("The units can not be zero when creating a stock dividend corporate action");

            this.CorporateActionType = CorporateActionTypes.StockDividend;
            this.CorporateActionDetails = dividendDetails;
            this.PreviousSize = previousSize;
        }
Example #3
0
 public DividendHistoryDetails(IDividendHistory history)
 {
     if (history != null)
     {
         this.IsStockDiv = history.NeedsStockDividend;
         this.Key = history.Key;
         this.DividendType = history.DividendType;
         this.Fund = history.Instrument;
         this.FundID = history.Instrument.Key;
         this.ExDividendDate = history.ExDividendDate;
         this.SettlementDate = history.SettlementDate;
         this.UnitPrice = history.UnitPrice != null ? history.UnitPrice.Quantity : 0M;
         this.ScripRatio = history.ScripRatio;
         this.ExtDescription = history.Description;
         this.IsExecuted = history.IsExecuted;
         this.IsInitialised = history.IsInitialised;
         this.IsGelicht = history.IsGelicht;
         this.DividendTaxStyle = (int)history.TypeOfDividendTax;
         this.TaxPercentage = history.TaxPercentage;
         this.StockDivIsin = history.StockDivIsin;
         this.TotalDividendDeposited = history.TotalNumberOfUnits;
         this.TotalUnitsInPossession = this.IsStockDiv ? history.StockDividends.Get(e => e.TotalUnits).GetS(e => e.DisplayString) : history.CashDividends.Get(e => e.TotalUnits).GetS(e => e.DisplayString);
         this.TotalDividendAmount = this.IsStockDiv ? history.StockDividends.Get(e => e.TotalDividendAmount).GetS(e => e.DisplayString) : history.CashDividends.Get(e => e.TotalDividendAmount).GetS(e => e.DisplayString);
     }
 }
Example #4
0
        protected static Price updateStockDividendPrices(IDalSession session, IStockDividend instrument, IDividendHistory history)
        {
            if (instrument == null)
                throw new ApplicationException("Stuff");

            Price price = new Price(history.UnitPrice.Quantity, instrument.CurrencyNominal, instrument);
            IList<IHistoricalPrice> historicalPrices = HistoricalPriceMapper.GetHistoricalPrices(session, instrument.Key, history.ExDividendDate, history.SettlementDate);
            DateTime priceDate = history.ExDividendDate;

            while (priceDate <= history.SettlementDate)
            {
                IHistoricalPrice historicalPrice = historicalPrices.Where(x => x.Date == priceDate).FirstOrDefault();
                if (historicalPrice == null)
                {
                    historicalPrice = new HistoricalPrice(price, priceDate);
                    instrument.HistoricalPrices.AddHistoricalPrice(historicalPrice);
                    InstrumentMapper.Update(session, instrument);
                }
                else
                {
                    if (historicalPrice.Price != price)
                    {
                        historicalPrice.Price = price;
                        HistoricalPriceMapper.Update(session, historicalPrice);
                    }
                }

                priceDate = priceDate.AddDays(1);
            }
            return price;
        }