public FutureTransactionPricer(ILogger logger, ICoreCache cache, string nameSpace, DateTime tradeDate, ExchangeContractTypeEnum futuresType, IBusinessCalendar settlementCalendar, FutureTransaction futureFpML, string basePartyReference, Boolean forecastRateInterpolation) { logger.LogInfo("FuturesType set. Commence to build a future transaction."); if (futureFpML == null) { return; } Multiplier = 1.0m; BuyerReference = futureFpML.buyerPartyReference.href; PaymentCurrencies = new List <string> { futureFpML.unitPrice.currency.Value }; SellerReference = futureFpML.sellerPartyReference.href; BasePartyBuyer = basePartyReference == futureFpML.buyerPartyReference.href; if (!BasePartyBuyer) { Multiplier = -1.0m; } ForecastRateInterpolation = forecastRateInterpolation; SettlementCalendar = settlementCalendar; FuturesType = futuresType; ReferenceContract = futureFpML.future.id; var futuresCode = ReferenceContract.Split('-')[2]; NumberOfContracts = Convert.ToInt16(futureFpML.numberOfUnits); PurchasePrice = MoneyHelper.GetAmount(futureFpML.unitPrice.amount, futureFpML.unitPrice.currency.Value); var exchangeMIC = futureFpML.future.exchangeId; FuturesCurveName = CurveNameHelpers.GetExchangeTradedCurveName(futureFpML.unitPrice.currency.Value, exchangeMIC.Value, futuresCode); DiscountCurveName = CurveNameHelpers.GetDiscountCurveName(futureFpML.unitPrice.currency, true); FuturesTypeInfo = new FutureNodeStruct(); var exchangeMICData = InstrumentDataHelper.CreateEquityExchangeKey(nameSpace, exchangeMIC.Value); var exchangeData = cache.LoadItem <ExchangeConfigData>(exchangeMICData); if (exchangeData?.Data is ExchangeConfigData) { Exchange = (ExchangeConfigData)exchangeData.Data; FuturesTypeInfo.SpotDate = Exchange.SettlementDate; } if (futureFpML.future != null) { if (SettlementCalendar == null) { SettlementCalendar = BusinessCenterHelper.ToBusinessCalendar(cache, FuturesTypeInfo.SpotDate .businessCenters, nameSpace); } var future = XmlSerializerHelper.Clone(futureFpML.future); FuturesTypeInfo.Future = future; if (FuturesTypeInfo.SpotDate != null) { SettlementDate = GetSettlementDate(tradeDate, SettlementCalendar, FuturesTypeInfo.SpotDate); } //Instantiate the priceable future. NamedValueSet namedValueSet = PriceableAssetFactory.BuildPropertiesForAssets(nameSpace, FuturesTypeInfo.Future.id, tradeDate); var asset = AssetHelper.Parse(FuturesTypeInfo.Future.id, 0.0m, 0.0m); UnderlyingFuture = PriceableAssetFactory.Create(logger, cache, nameSpace, asset.Second, namedValueSet, null, null) as IPriceableFuturesAssetController; if (UnderlyingFuture != null) { RiskMaturityDate = UnderlyingFuture.GetRiskMaturityDate(); MaturityDate = RiskMaturityDate; LastTradeDate = UnderlyingFuture.LastTradeDate; } if (!PaymentCurrencies.Contains(futureFpML.future.currency.Value)) { PaymentCurrencies.Add(futureFpML.future.currency.Value); } logger.LogInfo("Futures transaction has been successfully created."); } else { logger.LogInfo("Futures type data not available."); } //Add payments like the settlement price if (!PurchasePrice.amountSpecified) { return; } var amount = PurchasePrice.amount * NumberOfContracts / 100; var settlementPayment = PaymentHelper.Create("FuturesSettlemetAmount", BuyerReference, SellerReference, amount, SettlementDate); AdditionalPayments = PriceableInstrumentsFactory.CreatePriceablePayments(basePartyReference, new[] { settlementPayment }, SettlementCalendar); if (!PaymentCurrencies.Contains(settlementPayment.paymentAmount.currency.Value)) { PaymentCurrencies.Add(settlementPayment.paymentAmount.currency.Value); } }
public FutureTransactionPricer(ILogger logger, ICoreCache cache, string nameSpace, DateTime tradeDate, ExchangeContractTypeEnum futuresType, IBusinessCalendar settlementCalendar, FutureTransaction futureFpML, string basePartyReference) : this(logger, cache, nameSpace, tradeDate, futuresType, settlementCalendar, futureFpML, basePartyReference, false) { }