/// <summary> /// Applies a dividend to the portfolio /// </summary> /// <param name="dividend">The dividend to be applied</param> public void ApplyDividend(Dividend dividend) { var security = Securities[dividend.Symbol]; // only apply dividends when we're in raw mode or split adjusted mode var mode = security.DataNormalizationMode; if (mode == DataNormalizationMode.Raw || mode == DataNormalizationMode.SplitAdjusted) { // longs get benefits, shorts get clubbed on dividends var total = security.Holdings.Quantity * dividend.Distribution; // assuming USD, we still need to add Currency to the security object _baseCurrencyCash.AddAmount(total); } }
/// <summary> /// Applies a dividend to the portfolio /// </summary> /// <param name="dividend">The dividend to be applied</param> /// <param name="liveMode">True if live mode, false for backtest</param> /// <param name="mode">The <see cref="DataNormalizationMode"/> for this security</param> public void ApplyDividend(Dividend dividend, bool liveMode, DataNormalizationMode mode) { // we currently don't properly model dividend payable dates, so in // live mode it's more accurate to rely on the brokerage cash sync if (liveMode) { return; } var security = Securities[dividend.Symbol]; // only apply dividends when we're in raw mode or split adjusted mode if (mode == DataNormalizationMode.Raw || mode == DataNormalizationMode.SplitAdjusted) { // longs get benefits, shorts get clubbed on dividends var total = security.Holdings.Quantity * dividend.Distribution; // assuming USD, we still need to add Currency to the security object _baseCurrencyCash.AddAmount(total); } }