Skip to main content

Client library for Signal Fabric

Project description

Signal Fabric Client

Official Python client library for Signal Fabric - a lightweight handler-based framework for generating market signals on demand.

Installation

pip install signal-fabric-client

Quick Start

from signal_fabric import GrpcClient, SignalOutcome
import signal_fabric
print(f"Using signal_fabric from: {signal_fabric.__file__}")

import json

with GrpcClient(host='localhost', port=9090, use_tls=False) as client:
    outcome : SignalOutcome = client.process_signal(
        target='spot:BTC/USDT',
        signal_name='rsi_binance',
        signal_op='compute_rsi',
        handler_request={
            "period":  14,
            "timeframe": "1h"
        }
    )
    # Check for errors first
    if outcome.errors:
        print('We got errors:')
        for err_id, err_message in outcome.errors.items():
            print(f"  - {err_id}: {err_message}")
        print(f"\nResult: {outcome.result}")
        if outcome.result_format:
            print(f"Result format: {outcome.result_format}")
        print(f"Computation: {outcome.computation}")
        if outcome.handler_request:
            print(f"Handler request (echoed): {outcome.handler_request}")
    else:
        if not outcome.result:
            print("Error: Empty result received")
        else:
            format_info = f"result_format: {outcome.result_format}\n" if outcome.result_format else ""
            print(f"""target: {outcome.target}
latest_rsi: {outcome.result['latest_rsi']}
regime: {outcome.result['regime']}
{format_info}computed_at: {outcome.computed_at}
handler_request (echoed): {outcome.handler_request if outcome.handler_request else 'None'}
""")

API Reference

GrpcClient

Constructor

GrpcClient(host: str = 'localhost', port: int = 50051, timeout: int = 30, ca_cert_path: str = None)

Parameters:

  • host (str): Server hostname or IP address (default: 'localhost')
  • port (int): Server port number (default: 50051)
  • timeout (int): Request timeout in seconds (default: 30)
  • ca_cert_path (str): Path to CA certificate for server verification (PEM format)

Methods

connect()

Establish connection to the server.

disconnect()

Close the connection to the server.

is_connected() -> bool

Check if client is currently connected.

process_signal(target, signal_name, signal_op, handler_request=None) -> SignalOutcome

Process a signal request.

Parameters:

  • target (str): Target for signal computation (e.g., 'BTC', 'ETH', 'AAPL')
  • signal_name (str): Signal handler name or profile name
  • signal_op (str): Operation to perform (e.g., 'analyze', 'greet')
  • handler_request (dict, optional): Request parameters as dictionary

Returns: SignalOutcome object

SignalOutcome

Result object containing the signal computation outcome.

Attributes

  • result (str): Signal result value
  • computation (str): Description of computation performed
  • computed_at (float): Unix timestamp when computed
  • errors (Dict[str, str]): Error codes and messages (or empty)
  • details (Dict[str, str]): Additional computation details (or empty)

Methods

has_errors() -> bool

Returns True if the outcome contains errors.

is_detailed() -> bool

Returns True if the outcome has errors or additional details.

Requirements

  • Python 3.8+
  • grpcio >= 1.76.0
  • protobuf >= 4.0.0

Server Setup

This client requires a running Signal Fabric server. To set up the server:

  1. Clone the Signal Fabric repository:

    git clone https://github.com/phasequant/signal-fabric.git
    cd signal-fabric
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Start the server:

    python src/server/main.py --config config.yaml
    

Version

Current version: 0.1.17

License

See LICENSE file for details.

Links

Support

For questions, issues, or contributions, please visit the GitHub repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

signal_fabric_client-0.1.17.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

signal_fabric_client-0.1.17-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file signal_fabric_client-0.1.17.tar.gz.

File metadata

  • Download URL: signal_fabric_client-0.1.17.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for signal_fabric_client-0.1.17.tar.gz
Algorithm Hash digest
SHA256 bb9063b5a46077bab9f6b47fd702859d831c131ad32e674c17fcad40c8dba47f
MD5 c7e5823dc94a78cae58d856e0eae2ade
BLAKE2b-256 646c66bf7ab2fe8550df40cf6cfbc596e2d3725ba1f5c7546f9b458e3c654664

See more details on using hashes here.

File details

Details for the file signal_fabric_client-0.1.17-py3-none-any.whl.

File metadata

File hashes

Hashes for signal_fabric_client-0.1.17-py3-none-any.whl
Algorithm Hash digest
SHA256 ddeefde5304fb797dd0095cb6f9f1a3bb837840e298c1dbaf3cbbf6b100f07e2
MD5 0be2a6150e62307280a9ac4e02bbbfb2
BLAKE2b-256 e719e22cca08867c54a495264678696405bd2e235144a2d949b10b8a4e8d95ad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page