public void Load_Otc_Instrument_Transaction()
        {
            var effectiveDate = new DateTimeOffset(2018, 1, 1, 0, 0, 0, TimeSpan.Zero);

            //    create the portfolio
            var portfolioCode = _testDataUtilities.CreateTransactionPortfolio(TestDataUtilities.TutorialScope);

            //    swap definition, this is uploaded in a client custom format
            var swapDefinition = new InstrumentDefinition(
                name: "10mm 5Y Fixed",
                identifiers: new Dictionary <string, InstrumentIdValue>
            {
                ["ClientInternal"] = new InstrumentIdValue(value: "SW-1")
            },
                definition: new ExoticInstrument(
                    instrumentFormat: new InstrumentDefinitionFormat("CustomSource", "CustomFormat", "0.1.2"),
                    content: "<customFormat>the definition of the swap uploaded in custom Xml or Json format. One would expect that it should contain the full custom swap detail.</customFormat>",
                    instrumentType: LusidInstrument.InstrumentTypeEnum.ExoticInstrument
                    ));

            //    create the swap
            var createSwapResponse = _instrumentsApi.UpsertInstruments(new Dictionary <string, InstrumentDefinition>
            {
                ["correlationId"] = swapDefinition
            });

            var swapId = createSwapResponse.Values.Values.Select(i => i.LusidInstrumentId).FirstOrDefault();

            //    create the transaction request
            var transaction = new TransactionRequest(

                //    unique transaction id
                transactionId: Guid.NewGuid().ToString(),

                //    instruments must already exist in LUSID and have a valid LUSID instrument id
                instrumentIdentifiers: new Dictionary <string, string>
            {
                [TestDataUtilities.LusidInstrumentIdentifier] = swapId
            },

                type: "Buy",
                totalConsideration: new CurrencyAndAmount(0.0M, "GBP"),
                transactionPrice: new TransactionPrice(0.0M),
                transactionDate: effectiveDate,
                settlementDate: effectiveDate,
                units: 1,
                source: "Custodian");

            //    add the transaction
            _transactionPortfoliosApi.UpsertTransactions(TestDataUtilities.TutorialScope, portfolioCode, new List <TransactionRequest> {
                transaction
            });

            //    get the transaction
            var transactions = _transactionPortfoliosApi.GetTransactions(TestDataUtilities.TutorialScope, portfolioCode);

            Assert.That(transactions.Values, Has.Count.EqualTo(1));
            Assert.That(transactions.Values[0].TransactionId, Is.EqualTo(transaction.TransactionId));
            Assert.That(transactions.Values[0].InstrumentUid, Is.EqualTo(swapId));
        }
Beispiel #2
0
        private void UpsertOtcToLusid(LusidInstrument instrument, string name, string idUniqueToInstrument)
        {
            // PACKAGE instrument for upsert
            var instrumentDefinition = new InstrumentDefinition(
                name: name,
                identifiers: new Dictionary <string, InstrumentIdValue>
            {
                ["ClientInternal"] = new InstrumentIdValue(value: idUniqueToInstrument)
            },
                definition: instrument
                );

            // put instrument into Lusid
            var response = _instrumentsApi.UpsertInstruments(new Dictionary <string, InstrumentDefinition>
            {
                ["someId1"] = instrumentDefinition
            });

            // Check the response succeeded and has no errors.
            Assert.That(response.Failed.Count, Is.EqualTo(0));
            Assert.That(response.Values.Count, Is.EqualTo(1));
        }
Beispiel #3
0
        /// <summary>
        /// Given a list of instruments and the name of an equity (if any), this method upsert these instruments
        /// to LUSID and return their response value.
        /// </summary>
        /// <returns></returns>
        private Dictionary <string, Instrument> UpsertInstrumentSetAndReturnResponseValues(
            List <LusidInstrument> instruments,
            string equityIdentifier = null)
        {
            // CREATE instrument upsert request
            var instrumentUpsertRequest = CreateInstrumentUpsertRequest(instruments);

            // CREATE upsert equity instrument request, if equityIdentifier is provided
            if (!equityIdentifier.IsNullOrEmpty())
            {
                // MERGE into one upsert dictionary of instruments to upsert
                var equityRequest = CreateEquityUpsertRequest(equityIdentifier);
                equityRequest.ToList().ForEach(r => instrumentUpsertRequest.Add(r.Key, r.Value));
            }

            // UPSERT and check the response succeeded with no errors.
            var response = _instrumentsApi.UpsertInstruments(instrumentUpsertRequest);

            Assert.That(response.Failed.Count, Is.EqualTo(0));
            Assert.That(response.Values.Count, Is.EqualTo(instrumentUpsertRequest.Count));
            return(response.Values);
        }
        private void SeedInstrumentMaster()
        {
            var upsertInstrumentsResponse = _instrumentsApi.UpsertInstruments(new Dictionary <string, InstrumentDefinition>
            {
                ["correlationId1"] = new InstrumentDefinition(
                    name: "VODAFONE GROUP PLC",

                    /*
                     *  Instruments are created with a set of identifiers
                     *  each under a different scheme
                     */
                    identifiers: new Dictionary <string, InstrumentIdValue>
                {
                    [FigiScheme]           = new InstrumentIdValue("BBG000C6K6G9"),
                    [CustomInternalScheme] = new InstrumentIdValue("INTERNAL_ID_1"),
                    [IsinScheme]           = new InstrumentIdValue("GB00BH4HKS39"),
                    [SedolScheme]          = new InstrumentIdValue("BH4HKS3")
                }
                    ),

                ["correlationId2"] = new InstrumentDefinition(
                    name: "BARCLAYS PLC",

                    /*
                     *  Instruments are created with a set of identifiers
                     *  each under a different scheme
                     */
                    identifiers: new Dictionary <string, InstrumentIdValue>
                {
                    [FigiScheme]           = new InstrumentIdValue("BBG000C04D57"),
                    [CustomInternalScheme] = new InstrumentIdValue("INTERNAL_ID_2"),
                    [IsinScheme]           = new InstrumentIdValue("GB0031348658"),
                    [SedolScheme]          = new InstrumentIdValue("3134865")
                }
                    ),

                ["correlationId3"] = new InstrumentDefinition(
                    name: "NATIONAL GRID PLC",

                    /*
                     *  Instruments are created with a set of identifiers
                     *  each under a different scheme
                     */
                    identifiers: new Dictionary <string, InstrumentIdValue>
                {
                    [FigiScheme]           = new InstrumentIdValue("BBG000FV67Q4"),
                    [CustomInternalScheme] = new InstrumentIdValue("INTERNAL_ID_3"),
                    [IsinScheme]           = new InstrumentIdValue("GB00BDR05C01"),
                    [SedolScheme]          = new InstrumentIdValue("BDR05C0")
                }
                    ),

                ["correlationId4"] = new InstrumentDefinition(
                    name: "SAINSBURY (J) PLC",

                    /*
                     *  Instruments are created with a set of identifiers
                     *  each under a different scheme
                     */
                    identifiers: new Dictionary <string, InstrumentIdValue>
                {
                    [FigiScheme]           = new InstrumentIdValue("BBG000BF0KW3"),
                    [CustomInternalScheme] = new InstrumentIdValue("INTERNAL_ID_4"),
                    [IsinScheme]           = new InstrumentIdValue("GB00B019KW72"),
                    [SedolScheme]          = new InstrumentIdValue("B019KW7")
                }
                    ),

                ["correlationId5"] = new InstrumentDefinition(
                    name: "TAYLOR WIMPEY PLC",

                    /*
                     *  Instruments are created with a set of identifiers
                     *  each under a different scheme
                     */
                    identifiers: new Dictionary <string, InstrumentIdValue>
                {
                    [FigiScheme]           = new InstrumentIdValue("BBG000BF4KL1"),
                    [CustomInternalScheme] = new InstrumentIdValue("INTERNAL_ID_5"),
                    [IsinScheme]           = new InstrumentIdValue("GB0008782301"),
                    [SedolScheme]          = new InstrumentIdValue("0878230")
                }
                    )
            });

            Assert.That(upsertInstrumentsResponse.Values, Has.Count.EqualTo(5));
        }