public static ILusidApiFactory FactoryForEnvironment() { return (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("FBN_ACCESS_TOKEN")) ? LusidApiFactoryBuilder.Build("secrets.json") : LusidApiFactoryBuilder.Build()); }
public void Multi_Threaded_ApiFactory_Tasks(int quoteCount, int threadCount) { var config = ApiConfigurationBuilder.Build("secrets.json"); var provider = new ClientCredentialsFlowTokenProvider(config); var date = new DateTimeOffset(2018, 1, 1, 0, 0, 0, TimeSpan.Zero); var request = Enumerable.Range(0, quoteCount).Select(i => new UpsertQuoteRequest( new QuoteId( new QuoteSeriesId( provider: "DataScope", priceSource: "BankA", instrumentId: "BBG000B9XRY4", instrumentIdType: QuoteSeriesId.InstrumentIdTypeEnum.Figi, quoteType: QuoteSeriesId.QuoteTypeEnum.Price, field: "mid"), effectiveAt: date.AddDays(i)), metricValue: new MetricValue( value: 199.23m, unit: "USD"), lineage: "InternalSystem")).ToDictionary(k => k.QuoteId.EffectiveAt.ToString(), v => v); var tasks = Enumerable.Range(0, threadCount).Select(x => Task.Run(() => { var factory = LusidApiFactoryBuilder.Build(config.ApiUrl, provider); var result = factory.Api <IQuotesApi>().UpsertQuotes("mt-scope", request); Assert.That(result.Failed, Is.Empty); Console.WriteLine($"{DateTimeOffset.UtcNow} {Thread.CurrentThread.ManagedThreadId} {result.Values.Count}"); })); Task.WaitAll(tasks.ToArray()); }
public void SetUp() { _apiFactory = LusidApiFactoryBuilder.Build("secrets.json"); _instrumentLoader = new InstrumentLoader(_apiFactory); _instrumentIds = _instrumentLoader.LoadInstruments(); _ordersApi = _apiFactory.Api <IOrdersApi>(); }
public void SetUp() { _apiFactory = LusidApiFactoryBuilder.Build("secrets.json"); _instrumentsApi = _apiFactory.Api <IInstrumentsApi>(); EnsurePropertyDefinition("CustomSector"); SeedInstrumentMaster(); }
public void OneTimeSetUp() { _testFolderName = "Test_Folder" + Guid.NewGuid(); _testFolder = "/" + _testFolderName; _factory = LusidApiFactoryBuilder.Build("secrets.json"); _filesApi = _factory.Api <IFilesApi>(); _foldersApi = _factory.Api <IFoldersApi>(); }
public void SetUp() { _apiFactory = LusidApiFactoryBuilder.Build("secrets.json"); _instrumentLoader = new InstrumentLoader(_apiFactory); _instrumentIds = _instrumentLoader.LoadInstruments(); _testDataUtilities = new TestDataUtilities(_apiFactory.Api <ITransactionPortfoliosApi>()); }
public void SetUp() { // Initialise the API factory _apiFactory = LusidApiFactoryBuilder.Build("secrets.json"); // Load default instruments which will be used in the tests var instrumentsLoader = new InstrumentLoader(_apiFactory); _instrumentIds = instrumentsLoader.LoadInstruments().OrderBy(x => x).ToList(); }
public void SetUp() { _factory = LusidApiFactoryBuilder.Build(); _foldersApi = _factory.Api <IFoldersApi>(); _testFolderId = _foldersApi.GetRootFolder(filter: "Name eq 'SDK_Test_Folder'").Values.SingleOrDefault()?.Id; var createFolder = new CreateFolder("/", "SDK_Test_Folder"); _testFolderId ??= _foldersApi.CreateFolder(createFolder).Id; }
public void SetUp() { var apiFactory = LusidApiFactoryBuilder.Build("secrets.json"); _transactionPortfoliosApi = apiFactory.Api <ITransactionPortfoliosApi>(); _testDataUtilities = new TestDataUtilities(_transactionPortfoliosApi); var instrumentsLoader = new InstrumentLoader(apiFactory); _instrumentIds = instrumentsLoader.LoadInstruments().OrderBy(x => x).ToList(); }
public void SetUp() { _apiFactory = LusidApiFactoryBuilder.Build("secrets.json"); _instrumentLoader = new InstrumentLoader(_apiFactory); _instrumentIds = _instrumentLoader.LoadInstruments(); _recipeApi = _apiFactory.Api <IConfigurationRecipeApi>(); _testDataUtilities = new TestDataUtilities( _apiFactory.Api <ITransactionPortfoliosApi>(), _apiFactory.Api <IInstrumentsApi>(), _apiFactory.Api <IQuotesApi>(), _apiFactory.Api <IStructuredMarketDataApi>()); }
public void SetUp() { var apiFactory = LusidApiFactoryBuilder.Build("secrets.json"); _instrumentsApi = apiFactory.Api <IInstrumentsApi>(); _transactionPortfoliosApi = apiFactory.Api <ITransactionPortfoliosApi>(); var instrumentLoader = new InstrumentLoader(apiFactory); _instrumentIds = instrumentLoader.LoadInstruments(); _testDataUtilities = new TestDataUtilities(apiFactory.Api <ITransactionPortfoliosApi>()); _systemConfigurationApi = apiFactory.Api <ISystemConfigurationApi>(); }
public void LinuxSocketLeakTest() // See DEV-7152 { ApiConfiguration config = ApiConfigurationBuilder.Build("secrets.json"); var provider = new ClientCredentialsFlowTokenProvider(config); var api = BuildApi(); api.CreatePortfolioGroup("sdktest", new CreatePortfolioGroupRequest("TestGroup", displayName: "TestGroup")); // This loop should eventually throw a SocketException: "Address already in use" once all the sockets have been exhausted for (int i = 0; i < 50_000; i++) { api = BuildApi(); PortfolioGroup result = api.GetPortfolioGroup("sdktest", "TestGroup"); Assert.That(result, Is.Not.Null); // Option 1: force dispose of ApiClient //api.Configuration.ApiClient.Dispose(); // Option 2: force all finalizers to run if (i % 100 == 0) { GC.Collect(); GC.WaitForPendingFinalizers(); } } /*** Local Functions ***/ IPortfolioGroupsApi BuildApi() { // An instance of HttpClient is created within LusidApiFactory.Configuration.ApiClient.RestClient // which wasn't being disposed ILusidApiFactory factory = LusidApiFactoryBuilder.Build(config.ApiUrl, provider); IPortfolioGroupsApi api = factory.Api <IPortfolioGroupsApi>(); return(api); } }
public void SetUp() { var apiFactory = LusidApiFactoryBuilder.Build("secrets.json"); _corporateActionSourcesApi = apiFactory.Api <ICorporateActionSourcesApi>(); }
public void SetUp() { var apiFactory = LusidApiFactoryBuilder.Build("secrets.json"); _quotesApi = apiFactory.Api <IQuotesApi>(); }
public void SetUp() { _factory = LusidApiFactoryBuilder.Build(); }
public void SetUp() { var apiFactory = LusidApiFactoryBuilder.Build("secrets.json"); _conventionsApi = apiFactory.Api <IConventionsApi>(); }
public List <PortfolioHolding> Run() { // tag::create-client-factory[] var secretsFile = "secrets.json"; var apiFactory = LusidApiFactoryBuilder.Build(secretsFile); // end::create-client-factory[] // tag::create-tx-portfolios-api[] var txPortoliosApi = apiFactory.Api <ITransactionPortfoliosApi>(); // end::create-tx-portfolios-api[] // tag::create-portfolio[] var scope = "GettingStartedScope"; var uuid = Guid.NewGuid().ToString(); var portfolioRequest = new CreateTransactionPortfolioRequest( displayName: $"Portfolio-{uuid}", code: $"id-{uuid}", created: new DateTimeOffset(2018, 1, 1, 0, 0, 0, TimeSpan.Zero), baseCurrency: "GBP" ); var portfolio = txPortoliosApi.CreatePortfolio(scope, portfolioRequest); var portfolioCode = portfolio.Id.Code; Console.WriteLine($"Portfolio Code: {portfolioCode}"); // end::create-portfolio[] // tag::upsert-instruments[] var instrumentsApi = apiFactory.Api <IInstrumentsApi>(); var figsiToCreate = new Dictionary <string, InstrumentDefinition> { ["BBG000C6K6G9"] = new InstrumentDefinition( name: "VODAFONE GROUP PLC", identifiers: new Dictionary <string, InstrumentIdValue> { ["Figi"] = new InstrumentIdValue(value: "BBG000C6K6G9") }) }; instrumentsApi.UpsertInstruments(figsiToCreate); // end::upsert-instruments[] // tag::get-instruments[] var instrumentsResponse = instrumentsApi.GetInstruments(identifierType: "Figi", requestBody: figsiToCreate.Keys.ToList()); var luidToName = instrumentsResponse.Values.ToDictionary(value => value.Value.LusidInstrumentId, value => value.Value.Name); var nameToLuid = instrumentsResponse.Values.ToDictionary(value => value.Value.Name, value => value.Value.LusidInstrumentId); // end::get-instruments[] // tag::upsert-transactions[] var transactions = new List <TransactionRequest>() { new TransactionRequest( transactionId: Guid.NewGuid().ToString(), type: "StockIn", instrumentIdentifiers: new Dictionary <string, string> { ["Instrument/default/LusidInstrumentId"] = nameToLuid["VODAFONE GROUP PLC"] }, transactionDate: new DateTimeOffset(2021, 3, 27, 0, 0, 0, TimeSpan.Zero), settlementDate: new DateTimeOffset(2021, 3, 28, 0, 0, 0, TimeSpan.Zero), transactionPrice: new TransactionPrice(103), units: 100, totalConsideration: new CurrencyAndAmount(amount: 103 * 100, currency: "GBP"), source: "Broker" ) }; txPortoliosApi.UpsertTransactions(scope: scope, code: portfolioCode, transactionRequest: transactions); // end::upsert-transactions[] // tag::get-holdings[] var holdingsResponse = txPortoliosApi.GetHoldings(scope: scope, code: portfolioCode, propertyKeys: new List <String>() { "Instrument/default/Name" }); foreach (var holding in holdingsResponse.Values) { Console.WriteLine($"{luidToName[holding.InstrumentUid]}, {holding.Units}, {holding.Cost.Amount}"); } // end::get-holdings[] return(holdingsResponse.Values); }
public void SetUp() { _apiFactory = LusidApiFactoryBuilder.Build("secrets.json"); }
public void SetUp() { var apiFactory = LusidApiFactoryBuilder.Build("secrets.json"); _instrumentsApi = apiFactory.Api <IInstrumentsApi>(); }