Grumson.Utilities.Taapi 1.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package Grumson.Utilities.Taapi --version 1.0.5                
NuGet\Install-Package Grumson.Utilities.Taapi -Version 1.0.5                
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="Grumson.Utilities.Taapi" Version="1.0.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Grumson.Utilities.Taapi --version 1.0.5                
#r "nuget: Grumson.Utilities.Taapi, 1.0.5"                
#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 Grumson.Utilities.Taapi as a Cake Addin
#addin nuget:?package=Grumson.Utilities.Taapi&version=1.0.5

// Install Grumson.Utilities.Taapi as a Cake Tool
#tool nuget:?package=Grumson.Utilities.Taapi&version=1.0.5                

TaapiClient

Overview

The TaapiClient class is designed to interact with the Taapi.io API for fetching various indicator values, posting bulk indicator requests, and managing API rate limits. It provides asynchronous methods for making API requests and includes error handling for common HTTP and API errors.

Suported exchanges:

  • Binance
  • Binance Futures
  • BinanceUs
  • Coinbase
  • Kraken
  • Bitstamp
  • WhiteBIT
  • ByBit
  • GateIo

Supported indicators:

  • RSI
  • macd
  • sma
  • ema
  • stochastic
  • bbands
  • supertrend
  • atr
  • stochrsi
  • ma
  • dmi

Properties

Name Type Description Default
_httpClient HttpClient A static instance used for making HTTP requests to the Taapi API. N/A
_baseUrl string The base URL of the Taapi API. "https://api.taapi.io"
_retryAfterSeconds int The number of seconds to wait before retrying a request after a rate limit is exceeded. 60

Constructors

TaapiClient(string baseUrl = "https://api.taapi.io", int retryAfterSeconds = 60)

Initializes a new instance of the TaapiClient class.

  • Parameters:
    • baseUrl: The base URL of the Taapi API (default: "https://api.taapi.io").
    • retryAfterSeconds: Time in seconds to wait before retrying after rate limit (default: 60).

Methods

Task<TaapiIndicatorValuesResponse> GetIndicatorAsync(string apiKey, string symbol, TaapiExchange exchange, TaapiCandlesInterval candlesInterval, TaapiIndicatorPropertiesRequest directParametersRequest)

Fetches indicator values asynchronously.

  • Parameters:

    • apiKey: The API key used for authentication (must not be null or empty).
    • symbol: The symbol for which the indicator is fetched (must not be null or empty).
    • exchange: The exchange on which the symbol is traded.
    • candlesInterval: The time interval for the candles.
    • directParametersRequest: The properties for the requested indicator (must not be null).
  • Returns:
    A Task<TaapiIndicatorValuesResponse> representing the fetched indicator values.

  • Exceptions:

    • ArgumentException: If required parameters are null or empty.
    • UnauthorizedAccessException: If the API key is invalid.
    • RateLimitExceededException: If the rate limit is exceeded.
    • Other exceptions for HTTP request errors.

[Obsolete] Task<List<TaapiBulkResponse>> PostBulkIndicatorsAsync(TaapiBulkRequest requests)

Deprecated. Posts multiple indicator requests in bulk. Use GetBulkIndicatorsResults instead.

  • Parameters:

    • requests: The request object containing multiple indicator requests.
  • Returns:
    A Task<List<TaapiBulkResponse>> containing the bulk response.

  • Exceptions:
    Same as GetIndicatorAsync.


Task<List<ITaapiIndicatorResults>> GetBulkIndicatorsResults(TaapiBulkRequest requests)

Fetches multiple indicator results asynchronously in bulk.

  • Parameters:

    • requests: The bulk request object containing multiple indicator requests.
  • Returns:
    A Task<List<ITaapiIndicatorResults>> containing the results of the requested indicators.

  • Exceptions:
    Same as GetIndicatorAsync.


TaapiBulkRequest CreateBulkRequest(string apiKey, List<TaapiBulkConstruct> bulkConstructList)

Creates a bulk request for fetching multiple indicators.

  • Parameters:

    • apiKey: The API key for authentication (must not be null or empty).
    • bulkConstructList: A list of bulk constructs for the indicators (must not be null).
  • Returns:
    A TaapiBulkRequest object.

  • Exceptions:

    • ArgumentException: If parameters are null or empty.

TaapiBulkConstruct CreateBulkConstruct(TaapiExchange exchange, string symbol, TaapiCandlesInterval candlesInterval, List<ITaapiIndicatorProperties> indicatorList)

Creates a bulk construct for a specific exchange, symbol, and interval, and includes a list of indicators.

  • Parameters:

    • exchange: The exchange where the symbol is traded.
    • symbol: The symbol for which to create the bulk construct (must not be null or empty).
    • candlesInterval: The interval for the candles.
    • indicatorList: A list of indicators (must not be null or empty).
  • Returns:
    A TaapiBulkConstruct object.

  • Exceptions:

    • ArgumentException: If parameters are null or empty.

Exceptions

  • UnauthorizedAccessException: Thrown if the API key is invalid or unauthorized.
  • RateLimitExceededException: Thrown when the API's rate limit is exceeded.
  • ArgumentException: Thrown if invalid or missing parameters are provided.
  • HttpRequestException: Thrown when there is an error in the HTTP request.
  • JsonException: Thrown when JSON serialization/deserialization fails.
  • UriFormatException: Thrown if the URI format is invalid.

Example Usage

Here is an example of how to use the TaapiClient class to retrieve indicator values in console application: Make sure to replace "YOUR_API_KEY" with your actual Taapi API key.


using TaapiLibrary;
using TaapiLibrary.Contracts.Requests;
using TaapiLibrary.Contracts.Requests.Interfaces;
using TaapiLibrary.Contracts.Response.Bulk.Interfaces.Indicators;
using TaapiLibrary.Enums;
using TaapiLibrary.Models.Indicators.Properties;


Console.WriteLine("Taapi Test App");


string TAAPI_API_KEY = "YOUR_API_KEY";

TaapiClient taapiClient = new TaapiClient();


// Create BNBUSDT list of indicators properties and add properties for each indicator
List<ITaapiIndicatorProperties> bnb_PropertiesList = new List<ITaapiIndicatorProperties>();
// Rsi propertie
RsiIndicatorPropertie rsi_bnb = new RsiIndicatorPropertie { 
    Id = "rsi_bnb",
    Chart = TaapiChart.Candles,
    Backtrack = 0,
    Period = 10,
};
bnb_PropertiesList.Add(rsi_bnb);
// SuperTrend propertie
SuperTrendIndicatorProperties superTrend_bnb = new SuperTrendIndicatorProperties {
    Id = "supertrend_bnb",
    Chart = TaapiChart.Candles,
    Backtrack = 1,
    Period = 10,
    Multiplier = 3,
};
bnb_PropertiesList.Add(superTrend_bnb);
// Stoch rsi propertie
StochRsiIndicatorProperties stochRsi_bnb = new StochRsiIndicatorProperties {
    Id = "stochrsi_bnb",
    Chart = TaapiChart.Candles,
    Backtrack = 0,
    ChartGaps = false,
    DPeriod = 10,
    KPeriod = 9,
    RsiPeriod = 11,
    StochasticPeriod = 12,
};
bnb_PropertiesList.Add(stochRsi_bnb);

// Create Binance Futures BNBUSDT Bulk Construct from indicators properties ( rsi, superTrend, stochRsi,... )
var bnb_Construct = taapiClient.CreateBulkConstruct(TaapiExchange.BinanceFutures, "BNB/USDT", TaapiCandlesInterval.OneMinute, bnb_PropertiesList);



// Create BTCUSDT list of indicators properties and add properties for each indicator
List<ITaapiIndicatorProperties> btc_PropertiesList = new List<ITaapiIndicatorProperties>();
// MACD propertie
MacdIndicatorPropertie macd_bnb = new MacdIndicatorPropertie {
    Id = "macd_bnb",
    Chart = TaapiChart.Heikinashi,
    Backtrack = 0,
    OptInFastPeriod = 10,
    OptInSignalPeriod = 11,
    OptInSlowPeriod = 12,
};
btc_PropertiesList.Add(macd_bnb);

// Create Binance Futures BTCUSDT 5 min candle interval Bulk Construct from indicators properties ( MACD,... )
var btc_Construct = taapiClient.CreateBulkConstruct(TaapiExchange.BinanceFutures, "BTC/USDT", TaapiCandlesInterval.FiveMinutes, btc_PropertiesList);



List<TaapiBulkConstruct> constructs = new List<TaapiBulkConstruct>();
constructs.Add(bnb_Construct);
constructs.Add(btc_Construct);


// Get Bulk request for all indicators ( max 3 Constructs )
var bulk = taapiClient.CreateBulkRequest(TAAPI_API_KEY, constructs);


// Get results for indicators
var results = await taapiClient.GetBulkIndicatorsResults(bulk);


// Print results
if(results?.Count > 0) {
    foreach (var result in results) {

        // Get symbol from Id
        string symbol = result.Id.Split("_")[1].ToUpper();

        // RSI
        if (result is IRsiIndicatorResults rsiResult) {
            Console.WriteLine($"Symbol: {symbol} - RSI: {rsiResult.Value}");
        }
        // SuperTrend
        else if (result is ISuperTrendIndicatorResults superTrendResult) {
            Console.WriteLine($"Symbol: {symbol} - SuperTrend: {superTrendResult.Value} - {superTrendResult.ValueAdvice}");
        }
        // Stoch RSI
        else if (result is IStochRsiIndicatorResults stochRsiResult) {
            Console.WriteLine($"Symbol: {symbol} - " +
                $"Stoch RSI FastK:{stochRsiResult.ValueFastK} - FastD:{stochRsiResult.ValueFastD}");
        }
        // MACD
        else if (result is IMacdIndicatorResults macdResult) {
            Console.WriteLine($"Symbol: {symbol} - MACD: {macdResult.ValueMACD} - Hist:{macdResult.ValueMACDHist} - Signal:{macdResult.ValueMACDSignal}");
        }


    }// foreach
}

Console.WriteLine("End of program");

Changelog

This section outlines the changes and improvements made in each version of the TaapiLibrary.

Version 1.0.5 - 2023-07-26

Added

  • defoult values for Indicator Properties

Version 1.0.4 - 2023-07-24

Added

  • Task<List<ITaapiIndicatorResults>> GetBulkIndicatorsResults(TaapiBulkRequest requests)
  • TaapiBulkConstruct CreateBulkConstruct(TaapiExchange exchange, string symbol, TaapiCandlesInterval candlesInterval, List<ITaapiIndicatorProperties> indicatorList)
  • TaapiBulkRequest CreateBulkRequest(string apiKey, List<TaapiBulkConstruct> bulkConstructList)

Deprecated

  • [Obsolete] Task<List<TaapiBulkResponse>> PostBulkIndicatorsAsync(TaapiBulkRequest requests)

Version 1.0.3-alpha - 2023-07-18

Added

  • Posibility to set the TaapiClient base URL in the constructor.
  • Support for additional exchanges in TaapiExchange.cs.

Improved

  • Performance optimizations in the TaapiClient class for faster API responses.

Fixed

  • Fixed an issue where RateLimitExceededException was not correctly handled in some scenarios.

Version 1.0.2 - 2023-07-16

Added

Improved

  • Some minor improvements.

Fixed

  • Some minor bug fixes and improvements.

Version 1.0.1 - 2023-07-15

Added

Improved

  • Some minor improvements.

Fixed

  • Some minor bug fixes and improvements.

Version 1.0.0 - 2023-07-15

  • Initial release of the TaapiLibrary.
  • Support for basic indicator retrieval and bulk indicator requests.

Bulk Request

Bulk Response

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Grumson.Utilities.Taapi:

Package Downloads
Grumson.Utilities.Taapi.Signals

Powerful and easy-to-use library designed for building and managing trading signals using Finite State Machines (FSM). This library integrates seamlessly with the Taapi.io API, allowing users to leverage a wide range of trading indicators for creating custom trading strategies.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.3 111 1/20/2025
2.0.2 64 1/19/2025
2.0.1 75 1/11/2025
2.0.0 59 1/9/2025
1.1.1 92 1/5/2025
1.1.0 113 1/3/2025
1.0.9 92 1/2/2025
1.0.8 83 12/31/2024
1.0.7 120 10/10/2024
1.0.6 102 10/10/2024
1.0.5 109 9/26/2024
1.0.4 99 9/24/2024
1.0.3 108 7/18/2024
1.0.2 101 7/16/2024
1.0.1 94 7/15/2024
1.0.0 92 7/15/2024