0

I want to use this library AlphaVantage.NET. I've tried the demo

string apiKey = "1"; // enter your API key here

var client = new AlphaVantageStocksClient(apiKey);

// retrieve daily time series for stocks of Apple Inc.:
StockTimeSeries timeSeries = await client.RequestDailyTimeSeriesAsync("AAPL", TimeSeriesSize.Compact, adjusted: false);
foreach (var dataPoint in timeSeries.DataPoints)
{
    Console.WriteLine($"{dataPoint.Time}: {dataPoint.ClosingPrice}");
}

// retrieve stocks batch quotes for Apple Inc. and Facebook Inc.:
ICollection<StockQuote> batchQuotes = await client.RequestBatchQuotesAsync(new[] { "AAPL", "FB" });
foreach (var stockQuote in batchQuotes)
{
    Console.WriteLine($"{stockQuote.Symbol}: {stockQuote.Price}");
}

But...is there any option to add a Proxy like in Using-WebClient? For example:

using (WebClient wc = new WebClient())
{
    IWebProxy proxy = WebRequest.GetSystemWebProxy();
    proxy.Credentials = CredentialCache.DefaultCredentials;

    wc.Proxy = proxy;
    var json = wc.DownloadString(@"https://www.alphavantage.co/query?function=TIME_SERIES_WEEKLY&symbol=BLDP&apikey=#############");
}

Sorry for my bad english :/

Palle Due
  • 5,929
  • 4
  • 17
  • 32
  • Perhaps you should respond to this [open issue](https://github.com/LutsenkoKirill/AlphaVantage.Net/issues/8) to get more control over the HttpClient being used. – pritaeas Jan 02 '20 at 11:26

1 Answers1

1

Unfortunately not.

Looking at the source of the library, there's no way of intercepting/injecting the underlying http client being used. The client is private to the library and being new'ed up as a static in the Core project here: https://github.com/LutsenkoKirill/AlphaVantage.Net/blob/master/AlphaVantage.Net/src/AlphaVantage.Net.Core/AlphaVantageCoreClient.cs#L24

Claus
  • 1,975
  • 18
  • 24
  • Well.. it isn't too much work to fork the repository and add in support for injecting the HttpClient instead to be able to support proxy. See: https://github.com/clausjensen/AlphaVantage.Net/commit/c54352474242f19be02d22fcdded63cd7a07fd43 – Claus Jan 03 '20 at 09:08