public bool Apply(IPortfolio p, ITrade t) { if (t.type != tradeTypes.Buy) return true; if (t.price * t.quantity > p.Cash) { InsufficientFunds ex = new InsufficientFunds(); ex.Data.Add("AvailableFunds", p.Cash); ex.Data.Add("TransactionAmount", t.price * t.quantity); throw ex; } return true; }
public bool Apply(IPortfolio p, ITrade t) { if (t.type != tradeTypes.Buy) { return(true); } if (t.price * t.quantity > p.Cash) { InsufficientFunds ex = new InsufficientFunds(); ex.Data.Add("AvailableFunds", p.Cash); ex.Data.Add("TransactionAmount", t.price * t.quantity); throw ex; } return(true); }