Metadata-Version: 2.2
Name: liberal_alpha
Version: 0.1.6
Summary: Liberal Alpha Python SDK for interacting with gRPC-based backend
Home-page: https://github.com/capybaralabs-xyz/Liberal_Alpha
Author: capybaralabs
Author-email: donny@capybaralabs.xyz
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: grpcio>=1.40.0
Requires-Dist: protobuf>=3.20.0
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# Liberal Alpha SDK Usage Example

## 1️⃣ Initialize the SDK

You can initialize the SDK with default parameters:

```python
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.
