Example #1
0
 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)
 {
 }
Example #2
0
        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;
        }