c# - C# AlphaVantage.NET: How-to use Proxy
问题描述
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 :/
解决方案
不幸的是没有。
查看库的源代码,无法拦截/注入正在使用的底层 http 客户端。客户端对库是私有的,并在此处作为核心项目中的静态更新:https://github.com/LutsenkoKirill/AlphaVantage.Net/blob/master/AlphaVantage.Net/src/AlphaVantage.Net。核心/AlphaVantageCoreClient.cs#L24
推荐阅读
- swift - SwiftUI ObservedObject Binding KeyPath 下标错误
- mysql - 如何在 NodeJS 上处理 MySQL 断开连接?
- python - 试图指定命令行参数但无法弄清楚 - 不完全确定 optparse 中的 'dest' 和 'store' 做什么
- google-cloud-platform - 使用 Dataproc 将 Google Pub/Sub 与 Flink Streaming 结合使用的正确方法是什么?
- azure - 我可以从 .ps1 文件运行 powershell 命令吗?
- sql - 更新表错误:无法修改映射到非键保留表的列
- algorithm - 递归关系的时间复杂度:T(n) = nT(n^1/2)+ O(1)
- scala - 从 Spark 中的 Driver 访问任务进度
- ios - 如何修复 iOS 崩溃“com.apple.main-thread SIGABRT ABORT”
- mongodb - 在 Express 中哪里可以找到 Mongo Collection?