GithubHelp home page GithubHelp logo

de1m0s / alphavantage.net Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kirlut/alphavantage.net

0.0 0.0 0.0 255 KB

.Net client library for Alpha Vantage API

License: MIT License

C# 99.76% Shell 0.24%

alphavantage.net's Introduction

GitHub

AlphaVantage.Net

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

Release notes for version 2:

  • Most of the library classes were rewritten from scratch, keeping in mind all issues that were opened for the previous release.
  • New client works with System.Text.Json under the hood which is faster than classic Newtonsoft Json
  • Now you can create client's instances with 6 different constructors. It gives you access to underlying HttpClient + allow you to create wrappers around it if needed.
  • All packages were written using newest C# Nullable reference types feature, to reduce possible bugs

Packages:

  • AlphaVantage.Net.Core - low-level client for Alpha Vantage API based on HttpClient and System.Text.Json

Fully typed clients:

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:

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

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:

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

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:

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

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:

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

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:

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

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);
}

alphavantage.net's People

Contributors

rasodu avatar jacksteel97 avatar thomasvestergaard avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.