简体   繁体   English

C# AlphaVantage.NET:如何使用代理

[英]C# AlphaVantage.NET: How-to use Proxy

I want to use this library AlphaVantage.NET .我想使用这个库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?但是......是否有任何选项可以像在 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 :/对不起,我的英语不好 :/

Unfortunately not.不幸的是没有。

Looking at the source of the library, there's no way of intercepting/injecting the underlying http client being used.查看库的来源,无法拦截/注入正在使用的底层 http 客户端。 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客户端是库私有的,并在此处作为核心项目中的静态内容进行了新的更新: https : //github.com/LutsenkoKirill/AlphaVantage.Net/blob/master/AlphaVantage.Net/src/AlphaVantage.Net。核心/AlphaVantageCoreClient.cs#L24

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM