public NotaDividend(ICashDividend underlyingBooking) : base(underlyingBooking) { }
private static void executeBooking(ICashDividend booking, IFeeFactory feeFactory) { ITradeableInstrument instrument; if (booking.NeedToCreateCashInitiatedOrder(out instrument)) { Money divAmount = booking.Components.TotalAmount; if (instrument != null) { OrderAmountBased order = new OrderAmountBased(booking.Account, divAmount, instrument, true, feeFactory, true); order.OrderInfo = booking.Description; booking.CashInitiatedOrder = order; } else { // Sell from the biggest position IFundPosition pos = booking.Account.Portfolio.PortfolioInstrument.Where(x => x.Size.IsGreaterThanZero).OrderByDescending(x => x.CurrentValue).FirstOrDefault(); if (pos != null && (pos.CurrentBaseValue + divAmount).IsGreaterThanOrEqualToZero) { OrderAmountBased order = new OrderAmountBased(booking.Account, divAmount, pos.Instrument, true, feeFactory, true); order.OrderInfo = booking.Description; booking.CashInitiatedOrder = order; } } } booking.Execute(); }