mayankgrover / AlphaVantage.Net

.Net client library for Alpha Vantage API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AlphaVantage.Net

.Net client library for Alpha Vantage API.
Solution consist of two packages:

AlphaVantage.Net.Stocks

Installation:

  • Package Manager:
    Install-Package AlphaVantage.Net.Stocks -Version 1.0.2
  • .NET CLI:
    dotnet add package AlphaVantage.Net.Stocks --version 1.0.2

Usage example:

public async Task AlphaVantageStocksDemo()
{
    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}");
    }
}

AlphaVantage.Net.Core

Installation:

  • Package Manager:
    Install-Package AlphaVantage.Net.Core -Version 1.0.2
  • .NET CLI:
    dotnet add package AlphaVantage.Net.Core --version 1.0.2

Usage example:

public static async Task AlphaVantageCoreDemo()
{
    var coreClient = new AlphaVantageCoreClient();

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

    // retrieve stocks batch quoutes of Apple Inc. and Facebook Inc.:
    var query = new Dictionary<string, string>()
    {
         {"symbols", "FB,AAPL"}
    };
    JObject deserialisedResponse = await coreClient.RequestApiAsync(apiKey, ApiFunction.BATCH_STOCK_QUOTES, query);           
    // parse JObject here
}

About

.Net client library for Alpha Vantage API

License:MIT License


Languages

Language:C# 100.0%