Skip to content

Components

Components are the building blocks of GrailHub flows. Each component performs a specific function, from fetching market data to executing trades.

A component is a reusable piece of functionality that:

  • Accepts inputs (data it receives)
  • Produces outputs (data it generates)
  • Has configuration (settings that control its behavior)
  • Implements logic (the actual work it performs)

Inputs are the data a component receives. Each input has:

  • Name: Identifier for the input
  • Type: The data type (string, number, boolean, etc.)
  • Required: Whether the input must be connected

Example:

Inputs:
  - price: number (required)
  - volume: number (optional)

Outputs are the data a component produces. Each output has:

  • Name: Identifier for the output
  • Type: The data type it produces

Example:

Outputs:
  - signal: string
  - confidence: number

Configuration settings control the component’s behavior:

Configuration:
  - symbol: string (default: "BTCUSDT")
  - interval: string (default: "1m")
  - threshold: number (default: 50)

Components that fetch market data from exchanges:

  • Ticker: Real-time price updates
  • Orderbook: Current buy/sell orders
  • Trades: Recent trade history
  • Candles: OHLCV candlestick data

Components that calculate technical indicators:

  • RSI: Relative Strength Index
  • MACD: Moving Average Convergence Divergence
  • Bollinger Bands: Volatility bands
  • Moving Averages: SMA, EMA, WMA

Components that identify chart patterns:

  • Candlestick Patterns: Doji, Hammer, Engulfing, etc.
  • Chart Patterns: Head and Shoulders, Triangles, etc.

Components that control flow execution:

  • Condition: If/then logic
  • Switch: Multi-way branching
  • Loop: Repeat operations
  • Delay: Add time delays

Components that execute trades:

  • Market Order: Execute at market price
  • Limit Order: Execute at specific price
  • Stop Loss: Automatic loss prevention
  • Take Profit: Automatic profit taking

Components that send alerts:

  • Telegram: Send Telegram messages
  • Email: Send email notifications
  • Webhook: Call external APIs

Helper components:

  • Logger: Log data for debugging
  • Calculator: Perform calculations
  • Data Transform: Convert data formats
  • Storage: Save/load data
  1. Open the Components panel
  2. Search or browse for the component
  3. Drag it onto the canvas
  4. Configure its settings

Click on a component node to open its configuration panel:

  1. Set required configuration values
  2. Optionally set default input values
  3. Review input/output types
  4. Save changes

Connect components by dragging from an output handle to an input handle:

  1. Click and drag from the output (right side)
  2. Drop on a compatible input (left side)
  3. The edge will be created automatically

Components use typed inputs and outputs:

  • String: Text data
  • Number: Numeric values
  • Boolean: True/false values
  • Object: Complex data structures
  • Array: Lists of values
  • Any: Accepts any type

When a flow starts, each component:

  1. Validates its configuration
  2. Initializes internal state
  3. Prepares to receive data

During execution, components:

  1. Receive data on inputs
  2. Process the data
  3. Produce outputs
  4. Repeat

When a flow stops, components:

  1. Clean up resources
  2. Close connections
  3. Save state if needed

You can create your own components using Go:

type MyComponent struct {
    flow.BaseComponent
}

func (c *MyComponent) Inputs() []flow.Input {
    return []flow.Input{
        {ID: "input", Type: cty.Number},
    }
}

func (c *MyComponent) Outputs() []flow.Output {
    return []flow.Output{
        {ID: "output", Type: cty.Number},
    }
}

func (c *MyComponent) Process(ctx context.Context, inputs map[string]flow.InputChan, outputs map[string]flow.OutputChan) error {
    // Your logic here
    return nil
}

Select components that match your needs. Don’t overcomplicate with unnecessary components.

Always review and set appropriate configuration values.

Use error handling components to gracefully handle failures.

Test each component’s behavior before connecting them in complex flows.

Add comments to explain why you’re using specific components.