public static CashFlow CreateStrategy(Instrument instrument, BusinessDay initialDate, double amount, BusinessDay date, CashFlowGroup group) { if (instrument.InstrumentType == InstrumentType.Strategy) { CashFlow Strategy = new CashFlow(instrument); Strategy.Amount = amount; Strategy.Date = date.DateTime; //Strategy.AddMemoryPoint(DateTime.MinValue, amount, -(int)MemoryType.Amount); //Strategy.AddMemoryPoint(DateTime.MinValue, date.DateTime.ToOADate(), -(int)MemoryType.Date); if (group != null) { Strategy.Group = group; } //Strategy.AddMemoryPoint(DateTime.MinValue, group.ID, -(int)MemoryType.GroupID); double npv = Strategy.NPV(initialDate); Strategy.Startup(initialDate, npv, null); Strategy.InitialDate = new DateTime(1990, 01, 06); return(Strategy); } else { throw new Exception("Instrument not a Strategy"); } }
public void RemoveCashFlow(CashFlow cashFlow, DateTime date) { this.RemoveInstrument(cashFlow, DateTime.MinValue); Position position = this.Portfolio.FindPosition(cashFlow, date); if (position != null) { position.UpdatePosition(date, 0.0, cashFlow.NPV(Calendar.GetBusinessDay(date)), RebalancingType.Reserve, UpdateType.OverrideUnits); } cashFlow.Remove(); }
public void AddCashFlow(CashFlow cashFlow, DateTime date) { this.AddInstrument(cashFlow, date); this.Portfolio.CreatePosition(cashFlow, date, 1.0, cashFlow.NPV(Calendar.GetBusinessDay(date))); }