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 import initialize, liberal
initialize()
Or customize the parameters by providing your API key, private key, wallet address, and base URL. For example:
from liberal_alpha import initialize, liberal
from liberal_alpha.crypto import get_wallet_address
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)
initialize(
host="127.0.0.1",
port=8128,
api_key="YOUR_API_KEY",
private_key=private_key, # Used for decrypting messages (optional)
wallet=wallet, # Your wallet address
base_url="http://your-backend-url"
)
2️⃣ Send Data
Send a JSON object via gRPC:
JSON_Object = {
"Price": 100000,
"Volume": 50,
"Volume_USD": 5000000,
}
liberal.send_data("BTC_SOURCE1", JSON_Object, record_id="1")
3️⃣ Send Alpha Signal
Send an alpha signal:
alpha_data = {
"signal": "buy",
"confidence": 0.85
}
liberal.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:
liberal.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.
Project details
Release history Release notifications | RSS feed
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.6.tar.gz
(12.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file liberal_alpha-0.1.6.tar.gz.
File metadata
- Download URL: liberal_alpha-0.1.6.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd6ba94930a921c9d0a6c4ab16be0474cfe58ff22ec81a05e99ba9771ab180a4
|
|
| MD5 |
2ee63c00d7f085555e5449adcc832db8
|
|
| BLAKE2b-256 |
3a196774ca89884259df44069263d6d85a6eda09a0434a4e2b94b0a099c8e189
|
File details
Details for the file liberal_alpha-0.1.6-py3-none-any.whl.
File metadata
- Download URL: liberal_alpha-0.1.6-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f07574633fcbabe197c9a730095c08f3648b8349ec2bf64519ba2cb8533f4bc
|
|
| MD5 |
7b641df7a28ae762b15150616359ef23
|
|
| BLAKE2b-256 |
0753debc72b6c0313724d34ddd3e70f975fd6713e2399ec1a3b70827b9f595f8
|