kirlut / AlphaVantage.Net

.Net client library for Alpha Vantage API
MIT License
74 stars 39 forks source link
alphavantage api-client csharp finance netcore netstandard

GitHub

This project is in the archive.

Unfortunately, I don't have time to contribute to this repo anymore and publish updates. Feel free to fork and use it however you need to. If you would like to continue development and want to hold ownership of NuGet packages, please email me: lutkir@pm.me

AlphaVantage.Net

The most popular .Net client library for Alpha Vantage API.

Release notes for version 2:

Packages:

Documentation

AlphaVantage.Net.Core

Nuget (with prereleases) Nuget
This package allow you to request any available data from API, but you have to manually set all query parameters and retrieve information you need from the result

Installation:

Usage:

using System.Collections.Generic;
using System.Text.Json;
using System.Threading.Tasks;
using AlphaVantage.Net.Common;
using AlphaVantage.Net.Core.Client;

.....

public static async Task CoreDemo()
{
    // use your AlphaVantage API key
    string apiKey = "1";
    // there's 5 more constructors available
    using var client = new AlphaVantageClient(apiKey);

    // query for intraday time series for Apple Inc:
    var query = new Dictionary<string, string>()
    {
        {"symbol", "AAPL"},
        {"interval", "15min"}
    };

    // retrieve response as pure JSON string
    string stringResult = await client.RequestPureJsonAsync(ApiFunction.TIME_SERIES_INTRADAY, query);

    // retrieve response as parsed JsonDocument from System.Text.Json
    JsonDocument parsedResult = await client.RequestParsedJsonAsync(ApiFunction.TIME_SERIES_INTRADAY, query);
}

AlphaVantage.Net.Stocks

Nuget (with prereleases) Nuget

Installation:

Usage:

using System.Collections.Generic;
using System.Threading.Tasks;
using AlphaVantage.Net.Common.Intervals;
using AlphaVantage.Net.Common.Size;
using AlphaVantage.Net.Core.Client;
using AlphaVantage.Net.Stocks;
using AlphaVantage.Net.Stocks.Client;

.....

public static async Task StocksDemo()
{
    // use your AlphaVantage API key
    string apiKey = "1";
    // there are 5 more constructors available
    using var client = new AlphaVantageClient(apiKey);
    using var stocksClient = client.Stocks();

    StockTimeSeries stockTs = await stocksClient.GetTimeSeriesAsync("AAPL", Interval.Daily, OutputSize.Compact, isAdjusted: true);

    GlobalQuote globalQuote = await stocksClient.GetGlobalQuoteAsync("AAPL");

    ICollection<SymbolSearchMatch> searchMatches = await stocksClient.SearchSymbolAsync("BA");
}

AlphaVantage.Net.Forex

Nuget (with prereleases) Nuget

Installation:

Usage:

using System.Threading.Tasks;
using AlphaVantage.Net.Common.Currencies;
using AlphaVantage.Net.Common.Intervals;
using AlphaVantage.Net.Common.Size;
using AlphaVantage.Net.Core.Client;
using AlphaVantage.Net.Forex;
using AlphaVantage.Net.Forex.Client;

.....

public static async Task ForexDemo()
{
    // use your AlphaVantage API key
    string apiKey = "1";
    // there are 5 more constructors available
    using var client = new AlphaVantageClient(apiKey);
    using var forexClient = client.Forex();

    ForexTimeSeries forexTimeSeries = await forexClient.GetTimeSeriesAsync(
        PhysicalCurrency.USD, 
        PhysicalCurrency.ILS,
        Interval.Daily, 
        OutputSize.Compact);

    ForexExchangeRate forexExchangeRate = await forexClient.GetExchangeRateAsync(PhysicalCurrency.USD, PhysicalCurrency.ILS);
}

AlphaVantage.Net.Crypto

Nuget (with prereleases) Nuget

Installation:

Usage:

using System.Threading.Tasks;
using AlphaVantage.Net.Common.Currencies;
using AlphaVantage.Net.Common.Intervals;
using AlphaVantage.Net.Core.Client;
using AlphaVantage.Net.Crypto;
using AlphaVantage.Net.Crypto.Client;

.....

public static async Task CryptoDemo()
{
    // use your AlphaVantage API key
    string apiKey = "1";
    // there are 5 more constructors available
    using var client = new AlphaVantageClient(apiKey);
    using var cryptoClient = client.Crypto();

    CryptoTimeSeries cryptoTimeSeries =
        await cryptoClient.GetTimeSeriesAsync(DigitalCurrency.BTC, PhysicalCurrency.ILS, Interval.Weekly);

    CryptoRating cryptoRating = await cryptoClient.GetCryptoRatingAsync(DigitalCurrency.BTC);

    CryptoExchangeRate exchangeRate =
        await cryptoClient.GetExchangeRateAsync(DigitalCurrency.BTC, PhysicalCurrency.ILS);
}

AlphaVantage.Net.TechnicalIndicators

Nuget (with prereleases) Nuget
Since API endpoints from this section have many different additional parameters, you still need to check Alpha Vantage documentation in order to use it.

Installation:

Usage:

using System.Collections.Generic;
using System.Threading.Tasks;
using AlphaVantage.Net.Common.Intervals;
using AlphaVantage.Net.Core.Client;
using AlphaVantage.Net.TechnicalIndicators;
using AlphaVantage.Net.TechnicalIndicators.Client;

.....

public static async Task TechIndicatorsDemo()
{
    // use your AlphaVantage API key
    string apiKey = "1";
    // there are 5 more constructors available
    using var client = new AlphaVantageClient(apiKey);

    var symbol = "IBM";
    var indicatorType = TechIndicatorType.SMA;
    var query = new Dictionary<string, string>()
    {
        {"time_period", "20"},
        {"series_type", "close"}
    };

    TechIndicatorTimeSeries result = await client.GetTechIndicatorTimeSeriesAsync(symbol, indicatorType, Interval.Min15, query);
}