public override ITransaction Storno(IAccountTypeInternal stornoAccount, B4F.TotalGiro.Stichting.Login.IInternalEmployeeLogin employee, string reason, ITradingJournalEntry tradingJournalEntry) { ICrumbleTransaction newStorno = new CrumbleTransaction(); newStorno.Order = Order; this.storno(stornoAccount, employee, reason, tradingJournalEntry, newStorno); return newStorno; }
public InstrumentConversion(IAccountTypeInternal acctA, IAccount acctB, InstrumentSize valueSize, InstrumentSize convertedInstrumentSize, decimal exRate, IInstrumentHistory instrumentTransformation, ITradingJournalEntry tradingJournalEntry) : this(acctA, acctB, valueSize, convertedInstrumentSize, null, exRate, instrumentTransformation, tradingJournalEntry, null) { }
public CrumbleTransaction(IOrder order, ICrumbleAccount acctA, IAccount acctB, InstrumentSize valueSize, Price price, decimal exRate, DateTime transactionDate, DateTime transactionDateTime, Decimal ServiceChargePercentage, Side txSide, ITradingJournalEntry tradingJournalEntry, IGLLookupRecords lookups, ListOfTransactionComponents[] components) : base(order, acctA, acctB, valueSize, price, exRate, transactionDate, transactionDateTime, ServiceChargePercentage, txSide, tradingJournalEntry, lookups, components) { }
public override ITransaction Storno(IAccountTypeInternal stornoAccount, B4F.TotalGiro.Stichting.Login.IInternalEmployeeLogin employee, string reason, ITradingJournalEntry tradingJournalEntry) { IOrderAllocation newStorno = new OrderAllocation(); newStorno.Order = Order; this.storno(stornoAccount, employee, reason, tradingJournalEntry, newStorno); if (this.IsClientSettled) { newStorno.IsClientSettled = true; newStorno.ClientSettlementDate = this.ClientSettlementDate; } return newStorno; }
public TransactionNTM(IAccountTypeInternal acctA, IAccount acctB, InstrumentSize valueSize, Price price, decimal exRate, DateTime transactionDate, DateTime transactionDateTime, Decimal ServiceChargePercentage, Side txSide, ITradingJournalEntry tradingJournalEntry, IGLLookupRecords lookups, ListOfTransactionComponents[] components, string description) : base(acctA, acctB, valueSize, price, exRate, transactionDate, transactionDateTime, ServiceChargePercentage, txSide, tradingJournalEntry, lookups, components) { this.Description = description; }
protected void clientSettle(ITradingJournalEntry clientSettleJournal) { if (!IsClientSettled) { var lines = this.Components.SelectMany(x => x.JournalLines).Where(c => (c.GLAccount.IsToSettleWithClient && !c.IsSettledStatus)); foreach (IJournalEntryLine line in lines) line.ClientSettle(clientSettleJournal); clientSettleJournal.BookLines(); IsClientSettled = true; ClientSettlementDate = clientSettleJournal.TransactionDate; } }
public BonusDistribution(IAccountTypeInternal acctA, IAccount acctB, InstrumentSize valueSize, Price price, decimal exRate, DateTime transactionDate, DateTime transactionDateTime, Decimal ServiceChargePercentage, Side txSide, ICorporateActionBonusDistribution bonusDistributionDetails, ITradingJournalEntry tradingJournalEntry, IGLLookupRecords lookups, ListOfTransactionComponents[] components) : base(acctA, acctB, valueSize, price, exRate, transactionDate, transactionDateTime, ServiceChargePercentage, txSide, tradingJournalEntry, lookups, components) { this.CorporateActionType = CorporateActionTypes.BonusDistribution; this.CorporateActionDetails = bonusDistributionDetails; }
public InstrumentConversion(IAccountTypeInternal acctA, IAccount acctB, InstrumentSize valueSize, InstrumentSize convertedInstrumentSize, Money additionalCash, decimal exRate, IInstrumentHistory instrumentTransformation, ITradingJournalEntry tradingJournalEntry, IGLLookupRecords lookups) : base(acctA, acctB, valueSize, valueSize.GetPrice(0M), exRate, instrumentTransformation.ChangeDate, instrumentTransformation.ChangeDate, 0M, (valueSize.Sign ? Side.XI : Side.XO), tradingJournalEntry, lookups, null) { if (instrumentTransformation == null) throw new ApplicationException("Corporate action information is missing"); if (!(valueSize != null && valueSize.IsNotZero && convertedInstrumentSize != null && convertedInstrumentSize.IsNotZero)) throw new ApplicationException("Not all instrument information for this corporate action is available, both instruments have to be supplied"); if (valueSize.Underlying.Equals(convertedInstrumentSize.Underlying)) throw new ApplicationException("Both instruments can not be the same in a corporate action"); if (valueSize.Sign.Equals(convertedInstrumentSize.Sign)) throw new ApplicationException("Both instruments can not have the same side in a corporate action"); IInstrumentsHistoryConversion conversion = (IInstrumentsHistoryConversion)instrumentTransformation; if (!(conversion.Instrument.Equals(valueSize.Underlying) && conversion.NewInstrument.Equals(convertedInstrumentSize.Underlying))) throw new ApplicationException("Corporate action does not equal the instrument history data"); decimal diff = (convertedInstrumentSize.Abs().Quantity / valueSize.Abs().Quantity) - conversion.ConversionRate; if (diff != 0) throw new ApplicationException("Sizes do not correspond with conversion rate of the Corporate action"); if (additionalCash != null && additionalCash.IsNotZero) { ListOfTransactionComponents[] components = new ListOfTransactionComponents[1]; components[0] = new ListOfTransactionComponents() { ComponentType = BookingComponentTypes.Conversion, ComponentValue = additionalCash }; createComponents(lookups, components); } this.CorporateActionType = CorporateActionTypes.Conversion; ConvertedInstrumentSize = convertedInstrumentSize; CorporateActionType = instrumentTransformation.CorporateActionType; InstrumentTransformation = instrumentTransformation; }
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; }
//public static bool ApproveExecution(int tradeID) //{ // IDalSession session = NHSessionFactory.CreateSession(); // IInternalEmployeeLogin employee = LoginMapper.GetCurrentEmployee(session); // IOrderExecution exec = (IOrderExecution)TransactionMapper.GetTransaction(session, tradeID); // IList childrenOfExecution = B4F.TotalGiro.Orders.OldTransactions.ObsoleteTransactionMapper.GetNewExecutionChildren(session, tradeID); // exec.Approve(employee); // if ((exec.AccountA.AccountType == AccountTypes.Customer) || (exec.AccountB.AccountType == AccountTypes.Customer)) // { // //ITradingJournalEntry execSetlementJournal = TransactionAdapter.GetNewTradingJournalEntry(session, exec.TradingJournalEntry, exec.TransactionDate); // exec.ClientSettle(exec.TradingJournalEntry); // } // TransactionMapper.Update(session, exec); // session.Close(); // foreach (int childID in childrenOfExecution) // { // session = NHSessionFactory.CreateSession(); // IOrderExecutionChild child = (IOrderExecutionChild)TransactionMapper.GetTransaction(session, childID); // child.Approve(employee); // //ITradingJournalEntry childSetlementJournal = TransactionAdapter.GetNewTradingJournalEntry(session, child.TradingJournalEntry, child.TransactionDate); // child.ClientSettle(child.TradingJournalEntry); // TransactionMapper.Update(session, child); // session.Close(); // } // //Check the flag Isallocated // session = NHSessionFactory.CreateSession(); // exec = (IOrderExecution)TransactionMapper.GetTransaction(session, tradeID); // exec.SetIsAllocated(); // TransactionMapper.Update(session, exec); // session.Close(); // return true; //} //public static bool ClientSettleExecution(int executionTradeID) //{ // IDalSession session = NHSessionFactory.CreateSession(); // IOrderExecution exec = (IOrderExecution)TransactionMapper.GetTransaction(session, executionTradeID); // ITradingJournalEntry newEntry = GetNewTradingJournalEntry(session, exec.TradingJournalEntry, exec.TransactionDate); // exec.ClientSettle(newEntry); // TransactionMapper.Update(session, exec); // session.Close(); // return true; //} public static ITradingJournalEntry GetNewTradingJournalEntry(IDalSession session, ITradingJournalEntry unsettledJournal, DateTime transactionDate) { return GetNewTradingJournalEntry(session, unsettledJournal.Journal.Currency.Symbol.ToUpper(), transactionDate); }
public IOrderExecution Fill(InstrumentSize size, Price price, Money amount, decimal exRate, IAccount counterParty, DateTime transactionDate, DateTime transactionDateTime, IExchange exchange, bool isCompleteFill, Money serviceCharge, decimal serviceChargePercentage, Money accruedInterest, ITradingJournalEntry tradingJournalEntry, IGLLookupRecords lookups) { IOrderExecution returnValue = null; if (size == null || price == null || amount == null) throw new Exception("Size, Price and Amount are mandatory when filling the order."); if (IsFillable != OrderFillability.True) throw new ApplicationException("This Order is not fillable."); setSignServiceCharge(ref serviceCharge, ref serviceChargePercentage); if (accruedInterest != null && accruedInterest.IsNotZero) accruedInterest = accruedInterest.Abs() * (decimal)this.Side * -1M; CheckMaximalRoundOffError(IsSizeBased, size, amount, price, accruedInterest, this.Side); if (isCompleteFill) { // Check whether the order has not been filled before if (Transactions.Count > 0) throw new ApplicationException("The order has already been filled and so it can not be a complete fill."); if (this.OpenValue.IsZero) throw new ApplicationException("The open value of this order is zero."); InstrumentSize diff = getTradeDifferenceOpenValue(size, amount, serviceCharge, accruedInterest); if (diff.IsNotZero) { const decimal maxAllowed = 0.05m; // TickSize && NominalValue decimal tickSize = 0M; if (this.OrderType == OrderTypes.SizeBased) { IInstrumentExchange ie = getInstrumentExchange(exchange); if (ie != null) tickSize = ie.TickSize; } if (this.RequestedInstrument.SecCategory.Key == SecCategories.Bond) tickSize = ((IBond)this.RequestedInstrument).NominalValue.Quantity; if (!(tickSize > 0M && Math.Abs(diff.Quantity / tickSize) < 1M)) { decimal fillRatio = diff.Abs().Quantity / this.OpenValue.Abs().Quantity; if (fillRatio > maxAllowed) throw new ApplicationException( string.Format("The size of this transaction is different from the order size by more than {0:0.##}%.", maxAllowed * 100)); } } amount.XRate = exRate; } else { orderInitialCheck(ref amount, size, exRate, serviceCharge, accruedInterest); } this.IsCompleteFilled = isCompleteFill; orderCheckSide(this.Side, ref amount, ref size); checkServiceChargePercentage(serviceCharge, serviceChargePercentage, amount); ListOfTransactionComponents[] components = packageComponents(amount, serviceCharge, accruedInterest); returnValue = new OrderExecution(this, counterParty, size, price, exRate, transactionDate, transactionDateTime, serviceChargePercentage, tradingJournalEntry, lookups, components); fillOrder(returnValue, size, price, amount, serviceCharge, accruedInterest); return returnValue; }
public IOrderAllocation FillasAllocation(IOrderExecution ParentExecution, ITradingJournalEntry tradingJournalEntry, IGLLookupRecords lookups, IFeeFactory feeFactory) { if (!RequestedInstrument.IsTradeable) throw new Exception("FillasAllocation not possible when the instrument is not tradeable."); ITradeableInstrument instrument = (ITradeableInstrument)RequestedInstrument; IExchange exchange = ParentExecution.Exchange ?? instrument.DefaultExchange ?? instrument.HomeExchange; TransactionFillDetails details = instrument.GetTransactionFillDetails( this, ParentExecution.Price, ParentExecution.ContractualSettlementDate, feeFactory, ParentExecution.FillRatio, exchange); // convert servicecharge? if (details.ServiceCharge != null && details.ServiceCharge.IsNotZero) { if (!details.ServiceCharge.Underlying.Equals(ParentExecution.Price.Underlying) && !ParentExecution.Price.Underlying.IsObsoleteCurrency) details.ServiceCharge = details.ServiceCharge.Convert(ExRate, ParentExecution.Price.Underlying); } decimal exRate = (ExRate != 0 ? ExRate : ParentExecution.ExchangeRate); if (IsMonetary) exRate = ParentExecution.ExchangeRate; ListOfTransactionComponents[] components = packageComponents(details.Amount, details.ServiceCharge, details.AccruedInterest); OrderAllocation newTrade = new OrderAllocation( this, this.account, ParentExecution.AccountA, details.Size, ParentExecution.Price, exRate, ParentExecution.TransactionDate, ParentExecution.TransactionDateTime, details.ServiceChargePercentage, this.Side, feeFactory, tradingJournalEntry, lookups, components); newTrade.Exchange = ParentExecution.Exchange; newTrade.ContractualSettlementDate = ParentExecution.ContractualSettlementDate; if (details.Commission == null) instrument.CalculateCosts(newTrade, feeFactory, lookups); else newTrade.setCommission(lookups, details.Commission); fillOrder(newTrade, details.Size, ParentExecution.Price, details.Amount, details.ServiceCharge, details.AccruedInterest); ParentExecution.Allocations.AddAllocation(newTrade); return newTrade; }
public virtual void ClientSettle(ITradingJournalEntry clientSettleJournal) { clientSettle(this.TradingJournalEntry); }
public override ITransaction Storno(IAccountTypeInternal stornoAccount, B4F.TotalGiro.Stichting.Login.IInternalEmployeeLogin employee, string reason, ITradingJournalEntry tradingJournalEntry) { CorporateActionStockDividend newStorno = new CorporateActionStockDividend(); this.storno(stornoAccount, employee, reason, tradingJournalEntry, newStorno); return newStorno; }
public void ClientSettle(ITradingJournalEntry clientSettleJournal) { IJournalEntryLine newLine1 = new JournalEntryLine(); clientSettle(clientSettleJournal, newLine1, this.GLAccount, this.Balance.Negate(), this.BookComponent, this.GiroAccount); IJournalEntryLine newLine2 = new JournalEntryLine(); clientSettle(clientSettleJournal, newLine2, this.GLAccount.GLSettledAccount, this.Balance, this.BookComponent, this.GiroAccount); if (BookComponent.MainLine.Key == this.key) BookComponent.MainLine = newLine2; this.IsSettledStatus = true; }
public override ITransaction Storno(IAccountTypeInternal stornoAccount, IInternalEmployeeLogin employee, string reason, ITradingJournalEntry tradingJournalEntry) { ITransactionNTM newStorno = new TransactionNTM(); this.storno(stornoAccount, employee, reason, tradingJournalEntry, newStorno); return newStorno; }
public override ITransaction Storno(IAccountTypeInternal stornoAccount, B4F.TotalGiro.Stichting.Login.IInternalEmployeeLogin employee, string reason, ITradingJournalEntry tradingJournalEntry) { InstrumentConversion newStorno = new InstrumentConversion(); if (this.ConvertedInstrumentSize != null) newStorno.ConvertedInstrumentSize = this.ConvertedInstrumentSize.Negate(); this.storno(stornoAccount, employee, reason, tradingJournalEntry, newStorno); return newStorno; }