Av.API 0.2.0

dotnet add package Av.API --version 0.2.0
NuGet\Install-Package Av.API -Version 0.2.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Av.API" Version="0.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Av.API --version 0.2.0
#r "nuget: Av.API, 0.2.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Av.API as a Cake Addin
#addin nuget:?package=Av.API&version=0.2.0

// Install Av.API as a Cake Tool
#tool nuget:?package=Av.API&version=0.2.0

Build status

AV.NET

AV.NET is a C# library for AlphaVantage service.

Features

Currently, the API includes the following features:

  • Request daily data
  • Request weekly data
  • Request monthly data
  • Request currency exchange rate (crypto/currency)

Installation

You can clone the source code or use the nuget package.

Install-Package Av.API -Version 0.2.0

Requirements

The project require Microsoft Visual Studio 2015 or 2017.

Usage

The data can be retrieved using two methods:

  1. Directly using one the available provider (AvStockProvider or AvCurrencyProvider). Because of the limitation on the number of the requests and their frequency, when this method is used, it is your responsability to manage the delay between requests.
  2. Delegating the requests to one of the available request manager (AvStockRequestManager or AvCurrencyRequestManager).

Direct request

Fist you need to create the data provider, for stock data it is AvStockProvider and for currencies data it is AvCurrencyProvider. The constructor needs your AlphaVantage key as an argument.

AvStockProvider provider = new AvStockProvider(key);

Then you can call directly one of the available methods to retrieve the data

// Download daily data from 2000 (second argument = true)
StockData sgoDailyData = provider.RequestDaily("SGO.PA", true);

// Download weekly data
StockData sgoWeeklyData = provider.RequestWeekly("SGO.PA");

// Download monthly data
StockData sgoMonthlyData = provider.requestMonthly("SGO.PA", true);

// Download batch data (available only for US stocks)
IDictionary<string, StockRealtime> batchData = provider.BatchRequest(new string[] { "MSFT", "IBM", "AAPL" });

When using this method, you need to handle the dely between successive requests and errors.

Using RequestManager

The API provides types to manage the successive requests and the errors. Currently, two types are available:

  • AvStockRequestManager: for stock requests
  • AvCurrencyRequestManager: for currency requests

The following examples use the AvStockRequestManager but the same can be done with the other requests manager.

  1. Creating the request manager
AvStockRequestManager requestManager = new AvStockRequestManager(provider);
requestManager.Start();
  1. Add a request
requestManager.Add(StockRequestType.Daily, stock, Callback);
  1. Processing the results
private static void Callback(StockRequestType requestType, string symbol, StockData stockData)
{
    if (stockData == null)
    {
      Console.WriteLine("No {0} data received for symbol {1}", requestType.ToString(), symbol);
     }
     else
     {
         Console.WriteLine("Receiving {0} data for symbol {1}", requestType.ToString(), symbol);
         Console.WriteLine("\t{0} data", stockData.Data.Count);
         Console.WriteLine("\t{0}", stockData);
     }
}

Customize request processing

The Request Manager has several properties and methods to control the processing of the requests

Delay

This property is used to set the delay in milliseconds between two successive requests.

EnabledRetry

When set to true, the request manager will retry to download data if high usage error is received from AlphaVantage server. When high usage error is received, the request manager increased the delay between the requests.

MaxRetry

This property define the maximum number of successive retry when hig usage error is received.

Stopping the request manager

To stop the request manager thread, there is method Stop. If the argument finish is set to true, the request manager will process all the pending requests before effectively stop the thread.

Samples

Volume Chart

This program allows to input a stock and display the volume chart of last 100 trading days.

Volume Chart

Multiple Volume Chart

This program displays the volume chart of the last 100 trading days of one or more stocks. The stocks can be added and removed dynamically.

Multiple Volume Charts

Stock performance

This program computes and displays the performance of the stocks of the CAC40 indice vs a reference stock for the last 100 trading days.

Stock Performance

License

Apache License, Version 2.0

Open Source Components/Libraries

Product Compatible and additional computed target framework versions.
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.2.0 997 7/23/2018
0.1.0 980 7/10/2018

Alpha Vantage non official C# API.