Skip to main content

Liberal Alpha Python SDK for interacting with gRPC-based backend

Project description

Liberal Alpha SDK Usage Example

1️⃣ Initialize the SDK

You can initialize the SDK with default parameters:

from liberal_alpha.client import LiberalAlphaClient

private_key = "YOUR_PRIVATE_KEY"
# If wallet address is not provided, you can derive it from your private key:
wallet = get_wallet_address(private_key)

    client = LiberalAlphaClient(
        host="127.0.0.1",#optional
        port=8128,#optional
        api_key="api-key",#optional
        private_key=private_key #optional
    )
Send a JSON object via gRPC:
JSON_Object = {
    "Price": 100000,
    "Volume": 50,
    "Volume_USD": 5000000,
}

client.send_data("BTC_SOURCE1", JSON_Object, record_id="1")
3️⃣ Send Alpha Signal
Send an alpha signal:
alpha_data = {
    "signal": "buy",
    "confidence": 0.85
}

client.send_alpha("Alpha_ID", alpha_data, record_id="1")
4️⃣ Subscribe to Data
To subscribe to real-time data, use the subscribe_data method. Note that your API key, private key, wallet, and base URL are already set during initialization. You only need to specify the record to subscribe to and (optionally) provide an on_message callback for custom message handling. For example:
# Define a callback function to handle received messages
def on_message(message):
    print("Received message:", message)

# Subscribe to data from record_id 1:
client.subscribe_data(record_id=1, max_reconnect=5, on_message=on_message)

Ensure that your API Key, private key, and wallet address are correct, and that you have subscribed to the data you wish to receive via the website's subscribe channel.

Fetch My Records
To fetch the records associated with your account, use the my_records() method. This method makes an HTTP GET request to the backend endpoint /api/records using your API key for authentication, and returns the records in JSON format.

records = liberal.my_records()
print("My Records:", records)

Fetch My Subscriptions
To fetch your subscription information, use the my_subscriptions() method. This method sends an HTTP GET request to the backend endpoint /api/subscriptions with your API key for authentication, and returns the subscription details in JSON format.

subscriptions = liberal.my_subscriptions()
print("My Subscriptions:", subscriptions)

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

liberal_alpha-0.1.13.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

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

liberal_alpha-0.1.13-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

Details for the file liberal_alpha-0.1.13.tar.gz.

File metadata

  • Download URL: liberal_alpha-0.1.13.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.20

File hashes

Hashes for liberal_alpha-0.1.13.tar.gz
Algorithm Hash digest
SHA256 44932b57b49f321d7700b38a11a221207f1fd8964d1f750c942f82fa6a7698da
MD5 ebf47ce439e580f126657536eda626d7
BLAKE2b-256 62a4ebd742d71676c777cae041a161d5b29d5aa1e2c8d07b84e844a72db5b0f0

See more details on using hashes here.

File details

Details for the file liberal_alpha-0.1.13-py3-none-any.whl.

File metadata

  • Download URL: liberal_alpha-0.1.13-py3-none-any.whl
  • Upload date:
  • Size: 19.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.20

File hashes

Hashes for liberal_alpha-0.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 9ca2030f964b8896d0355b35a15521199bbcaca9e55686c2fc62e34ed67a2d12
MD5 800cc063fd4f78910c9717aa4d8d52e7
BLAKE2b-256 5fa9cee3ae0f04d7fb06f59eb35e2e454d69e3cbe1075efd32ee5c200b8b38eb

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