Grumson.Utilities.Taapi.Signals.Blazor 1.0.0

dotnet add package Grumson.Utilities.Taapi.Signals.Blazor --version 1.0.0                
NuGet\Install-Package Grumson.Utilities.Taapi.Signals.Blazor -Version 1.0.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="Grumson.Utilities.Taapi.Signals.Blazor" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Grumson.Utilities.Taapi.Signals.Blazor --version 1.0.0                
#r "nuget: Grumson.Utilities.Taapi.Signals.Blazor, 1.0.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 Grumson.Utilities.Taapi.Signals.Blazor as a Cake Addin
#addin nuget:?package=Grumson.Utilities.Taapi.Signals.Blazor&version=1.0.0

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

Razor Class Library - Taapi Signals Blazor UI

Table of Contents

  1. Introduction
  2. Project Structure
  3. Installation
  4. Usage
  5. Components Overview
  6. Example Usage
  7. Contributing
  8. License
  9. Support
  10. Changelog

Introduction

The Taapi Signals Blazor Razor Class Library (RCL) is a reusable component library built for managing and visualizing trading signals using the Taapi Signals Library. This Razor Class Library provides a UI layer for defining, testing, and managing trading signals in a structured manner, utilizing Finite State Machines (FSMs).

Key Features:

  • Component-Based Design - Modular Razor components for flexibility.
  • State Management - Create and modify FSM states.
  • Transition Management - Define transitions between states, based on indicators conditions.
  • Indicator Integration - Fetch real-time trading data via Taapi.io.
  • Signal Visualization - Graphical representation of signal behavior.
  • Signal Testing & Execution - Backtesting and live execution support.
  • Event-Driven Conditions - Define event-based conditions for signal transitions.
  • Stop Loss Management - Implement risk management within trading signals.

Project Structure

Taapi.Signals.Blazor.RCL/
│-- Components/
│   │-- Indicators/
│   │   ├── IndicatorManagementComponent.razor
│   │   ├── IndicatorViewComponent.razor
│   │   ├── IndicatorInfoRowViewComponent.razor
│   │-- Signals/
│   │   ├── SignalNameDescriptionCreationComponent.razor
│   │   ├── SignalNameDescriptionViewComponent.razor
│   │-- States/
│   │   |-- StopLosses/
│   │   │   ├── StopLossManagementComponent.razor
│   │   ├── StateManagementComponent.razor
│   │   ├── StateViewComponent.razor
│   │   ├── StateInfoRowViewComponent.razor
│   │-- Testing/
│   │   ├── SignalTestingComponent.razor
│   │   ├── IndicatorsTestingComponent.razor
│   │-- Transitions/
│   │   |-- Conditions/
│   │   │   |-- Indicator/
│   │   │   │   ├── IndicatorConditionManagementComponent.razor
│   │   │   ├── ConditionsManagementComponent.razor
│   │   │   ├── ConditionsViewComponent.razor
│   │   │   ├── ConditionsInfoRowViewComponent.razor
│   │   ├── TransitionManagementComponent.razor
│   │   ├── TransitionViewComponent.razor
│   │-- Visualization/
│   │   ├── SignalVisualizationComponent.razor
│   ├── SignalManagementComponent.razor
│-- wwwroot/
│   │-- js/
│   │   ├── fsm.js
│-- Services/
│   ├── SignalViewService.cs
│-- Managers/
│   ├── ITaapiSignalBlazorManager.cs
│   ├── TaapiSignalBlazorManager.cs
│-- Models/
│   │-- Testing/
│   │   ├── TestSignalViewData.cs
│   │-- Visualizations/
│   │   ├── GraphDataViewModel.cs
│   │   ├── GraphElementViewModel.cs
│   ├── TaapiConfig.cs
│-- Utils/
│   │-- FsmVisualizations/
│   │   ├── FsmVisualizationsService.cs
│-- ServiceCollectionExtensions.cs
│-- Taapi.Signals.Blazor.RCL.csproj

TaapiSignalBlazorManager Overview

Description

The TaapiSignalBlazorManager is responsible for managing trading signals, interacting with the Taapi Signals API, handling state transitions, and managing indicator data.

Core Methods
  • ValidateSignal(SignalModel signal): Validates a signal configuration before execution.
  • CreateSignal(SignalModel signal): Creates a new signal and subscribes to signal events.
  • TestSignal(TestSignalViewData testSignalViewData): Simulates signal transitions using test indicator data.
  • StartFetchingSignal(TimeSpan? interval): Starts fsm and start fetching live indicator data.
  • StopFetchingSignal(): Stops fsm and stop fetching live indicator data.
  • TestIndicatorsFetching(SignalModel signal): Tests fetching indicator values before live execution. And to see what values are being fetched.
Event Handling
  • OnNewActiveSignalState: Triggers when a new signal state is activated.
  • OnIndicatorValueFetched: Fires when an indicator value is fetched from Taapi.io.

Installation

Prerequisites

  • .NET 9.0 or higher: Ensure you have .NET SDK installed. You can download it from Microsoft's official site.
  • Taapi.io API Key: Sign up at Taapi.io and obtain an API key for accessing indicators. Free version of the API key will probably not work, because of the limitations of the free version of the API key.

Installation Steps

  1. Add the Taapi Signals Blazor RCL to your Blazor project:
    dotnet add package Taapi.Signals.Blazor --version x.x.x
    
  2. Add the required configuration values to appsettings.json:
    {
       "Taapi": {
        "TaapiKey": "YOUR_TAAPI_API_KEY",
        "TaapiSubscriptionType": "Pro" // Options: "Free" / "Basic" / "Pro" / "Enterprise" 
      }, 
    }
    
  3. Register the required dependencies in Program.cs:
    
    //MANDATORY: Add Taapi signals blazor services ( for components )
    builder.Services.AddSingletonTaapiSignalsBlazor(builder.Configuration);
    
    //OPTIONAL: Add Taapi Signal Manager
    
    // Register TaapiClient with configuration values (for SignalManager)
    builder.Services.AddSingleton<ITaapiClient>(provider => {
    
        var configuration = provider.GetRequiredService<IConfiguration>();
        var logger = provider.GetRequiredService<ILogger<TaapiClient>>();
        var apiKey = configuration["Taapi:TaapiKey"];
        var subscriptionType = configuration["Taapi:TaapiSubscriptionType"];
    
        if (!Enum.TryParse<SubscriptionType>(subscriptionType, out var subscriptionTypeEnum)) {
            throw new ArgumentException($"Invalid subscription type: {subscriptionType}");
        }
    
        return new TaapiClient(logger, apiKey, subscriptionTypeEnum);
    });
    // Register EventManager (for SignalManager)
    builder.Services.AddSingleton<IEventManager, EventManager>();
    // Register the SignalManager
    builder.Services.AddSingleton<ISignalManager, SignalManager>();
    
    
  4. Import the component library in _Imports.razor:
    @using Signals.Blazor.Components
    
  5. Import javascript dependencies in index.html:
    <script src="https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.20.0/cytoscape.min.js"></script>
    <script src="_content/Grumson.Utilities.Taapi.Signals.Blazor/js/fsm.js"></script>
    

Usage

Integrating Components

To use the components, simply add them to a page:

@page "/signals"

<SignalManagementComponent SignalModel="_signalModel" />

@code{
    private SignalModel _signalModel = new SignalModel();
}

Validating and testing a signal:


<SignalVisualizationComponent SignalModel="SignalModel" OnMessage="OnMessage" />

<SignalTestingComponent SignalModel="SignalModel" OnMessage="OnMessage" />

@code{
    private SignalModel _signalModel = new SignalModel();

    private void OnMessage(string message)
    {
        Console.WriteLine(message);
    }
}

This will render the UI for managing trading signals with dynamically bindings to the components.


Components Overview

1. Indicator Components

Component Description
IndicatorManagementComponent Manages indicators for trading signals.
IndicatorViewComponent Displays details of selected indicators.
IndicatorInfoRowViewComponent Renders a single indicator row.

2. Signal Components

Component Description
SignalManagementComponent Handles signal creation and modification.
SignalNameDescriptionCreationComponent Allows users to enter a signal name and description.
SignalNameDescriptionViewComponent Displays the name and description of a signal.

3. State Components

Component Description
StateManagementComponent UI for defining states in FSM-based signals.
StateViewComponent Displays signal states visually.
StateInfoRowViewComponent Displays a single state in a list view.
StopLossManagementComponent Implements risk management rules for each state.

3. Transition Components

Component Description
TransitionManagementComponent UI for configuring state transitions.
TransitionViewComponent Displays transition details.
ConditionsManagementComponent Manages conditions for signal transitions.
ConditionsViewComponent Displays a list of configured conditions.
ConditionsInfoRowViewComponent Displays a single condition in a list view.
IndicatorConditionManagementComponent Manages conditions based on indicator values.

5. Testing & Visualization Components

Component Description
SignalTestingComponent Provides a UI for testing trading signals.
IndicatorsTestingComponent Allows testing of indicator values independently.
SignalVisualizationComponent Graphically represents signal behavior.

Example Usage

Creating a New Signal with validation and testing

  1. Create,Validate and test the signal model:

    Signal management component is used to create, visualize, and test trading signals. Or you can use components individually to create a custom UI for managing signals.

  2. Create service and subscribe to signal events:

    Use the SignalManager to create a signal service and subscribe to signal events.

  3. Run FSM and auto fetching signal indicators with a time interval: Start the signal FSM and fetch real-time indicator values at a specified interval.

  4. Handle Signal Events: Implement event handlers for signal transitions, state changes, indicator value fetching and stop loss calculations. here you can put some actions to be excuted when these events are triggered. e.g. logging, sending notifications, etc.

@page "/signals"

@using Taapi.Signals.Managers
@using Taapi.Signals.Services

@rendermode InteractiveServer
@inject ISignalManager SignalManager


<PageTitle>Home</PageTitle>


<SignalManagementComponent SignalModel="_signalModel" />




@code{

    // Signal Model
    private SignalModel _signalModel = new SignalModel();


    // On Signal Created
    private async Task OnSignalCreated()
    {
        try {

            // Create Signal service and get the signal model Id
            _signalModel.Id = await SignalManager.CreateSignalService(_signalModel);

            // Register on signal service events
            SignalManager.SubscribeToEvents(_signalModel.Id,
                beforeTransition: BeforeTransitionEvent,
                afterTransition: AfterTransitionEvent,
                onEnterState: OnEnterStateEvent,
                onExitState: OnExitStateEvent,
                onIndicatorValueFetched: OnIndicatorValueFetchedEvent
                );

            // Register on stop loss calculated events
            foreach (var state in _signalModel.States)
            {
                if (state.StopLoss != null)
                {
                    state.StopLoss.OnStopLossCalculatedEvent += OnStopLossCalculated;
                }
            }

        }
        catch (InvalidOperationException ex) { 
        
            Console.WriteLine(ex.Message);
        }
        catch (ArgumentException ex)
        {
            Console.WriteLine(ex.Message);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
    }

    // Start Signal fsm
    private void StartSignal()
    {
        try
        {
            // Start auto fetching signal indicators with a time interval of 1 minute
            SignalManager.StartAutoFetching(_signalModel.Id, new TimeSpan(0, 1, 0));
        }
        catch (KeyNotFoundException ex)
        {
            Console.WriteLine(ex.Message);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }

    }//end StartSignal()

    // Stop Signal fsm
    private void StopSignal()
    {
        try
        {
            // Stop auto fetching signal indicators
            SignalManager.StopAutoFetching(_signalModel.Id);
        }
        catch (KeyNotFoundException ex)
        {
            Console.WriteLine(ex.Message);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }

    }//end StopSignal()


    #region Signal Events

    // Before Transition Event (this event is triggered first before transitioning to a new state)
    private static void BeforeTransitionEvent(SignalService service, StateTransition transition)
    {

        Console.WriteLine($"Before transitioning from {transition.FromState.Name} to {transition.ToState.Name}");
    }//end BeforeTransitionEvent()


    // On Exit State Event (this event is triggered second after transitioning to a new state)
    private static void OnExitStateEvent(SignalService service, SignalState state)
    {

        Console.WriteLine($"Exited state: {state.Name}");
    }//end OnExitStateEvent()


    // On Enter State Event (this event is triggered third after transitioning to a new state
    private static void OnEnterStateEvent(SignalService service, SignalState state)
    {

        Console.WriteLine($"Entered state: {state.Name}");
    }//end OnEnterStateEvent()


    // After Transition Event (this event is triggered last after transitioning to a new state)
    private static void AfterTransitionEvent(SignalService service, StateTransition transition)
    {

        Console.WriteLine($"After transitioning from {transition.FromState.Name} to {transition.ToState.Name}");
    }//end AfterTransitionEvent()


    // On Indicator Value Fetched Event
    private static void OnIndicatorValueFetchedEvent(string indicatorKey, object indicatorValue)
    {

        Console.WriteLine($"Indicator value fetched: {indicatorKey} = {indicatorValue}");
    }//end OnIndicatorValueFetchedEvent()


    // On Stop Loss Calculated Event
    public static void OnStopLossCalculated(string stateName, decimal stopLossValue)
    {

        Console.WriteLine($"Stop loss calculated for state {stateName}: {stopLossValue}");
    }//end OnStopLossCalculated()

    #endregion

}

Contributing

Contributions are welcome! If you have any questions, suggestions, or you want to contribute to this project, feel free to contact me at info@grumson.eu


License

This project is licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE for more information.


Support

Use this link to register on Taapi.io and you will support me with a small commission. Thank you!

If you realy like this project and you want to support it, you can donate to the following addresses:

Network BSC BNB smart chain (BEP20) : 0xd8c509ed7d8f96847618d926e2b831d804e02ece

  • BNB : 0xd8c509ed7d8f96847618d926e2b831d804e02ece
  • USDT : 0xd8c509ed7d8f96847618d926e2b831d804e02ece

Network Solana (SPL) : 4D1W3Vv2tbfAzuEgBSiNGqdtGT5wUjbodoF6mXEsnvTf

  • SOL : 4D1W3Vv2tbfAzuEgBSiNGqdtGT5wUjbodoF6mXEsnvTf
  • USDC : 4D1W3Vv2tbfAzuEgBSiNGqdtGT5wUjbodoF6mXEsnvTf

Network Ethereum (ERC20) : 0xd8c509ed7d8f96847618d926e2b831d804e02ece

  • ETH : 0xd8c509ed7d8f96847618d926e2b831d804e02ece
  • USDC : 0xd8c509ed7d8f96847618d926e2b831d804e02ece

BTC : 19pxXzh1Kzzw73v6iKbowr1DJro5ozgZj6


Changelog

Version 1.0.0 (31.01.2025)
  • Initial release of the Taapi Signals Blazor RCL.
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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

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
1.0.0 55 1/31/2025