/// <summary> /// Creates new instance of <see cref="AlpacaDataClient"/> object. /// </summary> /// <param name="configuration">Configuration parameters object.</param> public AlpacaDataClient( AlpacaDataClientConfiguration configuration) { configuration .EnsureNotNull(nameof(configuration)) .EnsureIsValid(); _httpClient.AddAuthenticationHeaders(configuration.SecurityId); _httpClient.DefaultRequestHeaders.Accept .Add(new MediaTypeWithQualityHeaderValue("application/json")); _httpClient.BaseAddress = configuration.ApiEndpoint; _httpClient.SetSecurityProtocol(); }
public AlpacaDataClient( AlpacaDataClientConfiguration configuration) { configuration .EnsureNotNull(nameof(configuration)) .EnsureIsValid(); _httpClient = configuration.HttpClient ?? configuration.ThrottleParameters.GetHttpClient(); _httpClient.AddAuthenticationHeaders(configuration.SecurityId); _httpClient.Configure(new UriBuilder( configuration.ApiEndpoint) { Path = "v2/stocks/" }.Uri); }
public AlpacaDataClient( AlpacaDataClientConfiguration configuration) { configuration .EnsureNotNull(nameof(configuration)) .EnsureIsValid(); _httpClient = configuration.HttpClient ?? configuration.ThrottleParameters.GetHttpClient(); _httpClient.AddAuthenticationHeaders(configuration.SecurityId); _httpClient.DefaultRequestHeaders.Accept .Add(new MediaTypeWithQualityHeaderValue("application/json")); _httpClient.DefaultRequestHeaders.AcceptEncoding .Add(new StringWithQualityHeaderValue("gzip")); _httpClient.BaseAddress = new UriBuilder( configuration.ApiEndpoint) { Path = "v2/stocks/" }.Uri; _httpClient.SetSecurityProtocol(); }