Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagec#
themeRDark
titleC# - CreateInstrument
linenumberstrue
collapsetrue
 //Create an instrument using the CreateInstruments method
var client = new BFSServiceReference.bfsapiSoapClient();

var credentials = new BFSServiceReference.Credentials()
{
    UserName = bfsusername, //Username of administrative user in your instance of BFS
    Password = bfspassword, //Password of the administrative user in your instance of BFS
};

var IC = new InstrumentCategorizationItem()
{    
    GroupKey = "Industry",
    Key = "Technology",
    Weight = 0.3
};

var response = client.CreateInstruments(new BFSServiceReference.CreateInstrumentRequest()
{
    Credentials = credentials,

    identify = bfsidentifier, //Identifier is a unique token for your instance of BFS

    Entities = new[]
    {
        new Instrument()
        {
            InstrumentType = 1,
            CurrencyCode = "SEK",
            ISIN = "SE0000108656",                        
            Name = "TestInstrument",
            Symbol = "TEST",
            TradingCalendar = "ForFutureUse", 
            SettlementCalendar = "ForFutureUse",
            QuantityDecimals = 2,
            DisplayDecimalsPrice = 2,
            ValueMultiplier = 1,
            DisplayMultiplier = 2,
            InstrumentStatus = 1,
            IsUnitOrder = true,
            InstrumentCategorization = new InstrumentCategorizationArray() 
            {
                Array = new InstrumentCategorizationItem[]
                {
                    IC,
                }
            },
            ExternalReference = "External system ID",
            TaxCountry = "SE",           
            Price = 100,
            DefaultMarketPlace = new Guid("25d5a96c-87f0-481f-a9b2-bc96e58012fd"),
            VisibleStatusKey = "Open"                                              

        }
    }

});

//Show information about the created instrument

foreach (var c in response.Entities)
{
    Console.WriteLine(c.BrickId + ", " + c.Errors);
}

...