
Security News
The Nightmare Before Deployment
Season’s greetings from Socket, and here’s to a calm end of year: clean dependencies, boring pipelines, no surprises.
alphasquared-py
Advanced tools
This is an unofficial Python client for the AlphaSquared API. It allows users to interact with the API to retrieve asset information, strategy values, and hypothetical data for cryptocurrency trading.
Install the package using pip:
pip install alphasquared-py
To use the AlphaSquared API, you need to obtain an API token from your AlphaSquared account dashboard. Once you have your token, you can authenticate as follows:
from alphasquared import AlphaSquared
api = AlphaSquared("YOUR_API_TOKEN")
You can also enable debug mode for more detailed logging during development:
api = AlphaSquared("YOUR_API_TOKEN", debug=True)
The client sends your token in the Authorization header as-is (no Bearer prefix required).
btc_info = api.get_asset_info("BTC")
print(btc_info)
strategy_values = api.get_strategy_values("My Custom Strat")
print(strategy_values)
eth_hypotheticals = api.get_hypotheticals("ETH")
print(eth_hypotheticals)
btc_comprehensive = api.get_comprehensive_asset_data("BTC")
print(btc_comprehensive)
action, value = api.get_strategy_value_for_risk("My Custom Strat", 50)
print(f"Action: {action}, Value: {value}")
Notes:
current_risk = api.get_current_risk("BTC")
print(current_risk)
This example demonstrates how to get the current risk for an asset, then use that risk level to determine the strategy action and value:
# Get the current risk for BTC
btc_risk = api.get_current_risk("BTC")
print(f"Current BTC Risk: {btc_risk}")
# Define your strategy name in AlphaSquared
strategy_name = "My Custom Strat"
# Get the strategy action and value for the current risk
action, value = api.get_strategy_value_for_risk(strategy_name, btc_risk)
print(f"For risk {btc_risk}: Action = {action.upper()}, Value = {value}")
The client includes built-in error handling. You can check for errors in the API responses:
result = api.get_asset_info("INVALID_ASSET")
if api.has_error(result):
print("An error occurred:", result["error"])
The client automatically handles rate limiting to ensure compliance with the API's usage rules (6 requests per minute).
The client uses caching to reduce the number of API calls. You can set the cache TTL (time-to-live) when initializing the client. The default cache TTL is 5 minutes.
api = AlphaSquared("YOUR_API_TOKEN", cache_ttl=300) # 5 minutes
The client includes configurable logging functionality. By default, logging is set to WARNING level. You can enable debug mode for more detailed logging during development:
api = AlphaSquared("YOUR_API_TOKEN", debug=True)
In production, sensitive information in request headers and responses is automatically redacted in logs.
The client supports retrieving strategy action signals and updating their execution status.
Fetch a single page (paginated):
latest = api.get_strategy_actions(strategy_name="My Strategy", page=1, per_page=50, executed=False)
for act in latest.get("actions", []):
print(act)
Executed filter:
executed=True → requests items marked executedexecuted=False → requests pending items (recommended for polling)executed="all" → returns both executed and pendingIterate across all pages (history):
for act in api.iter_strategy_actions(strategy_id=12345, per_page=100):
# Process each action dict
pass
Mark an action as executed (PATCH):
res = api.update_strategy_action_status(notification_id=9876, executed=True, strategy_name="My Strategy")
if api.has_error(res):
print("Failed:", res["error"])
Operational notes:
executed=False when fetching to avoid repeatedly seeing executed items; after executing on your exchange, patch the item to executed=True.End-to-end example:
page = api.get_strategy_actions(strategy_name="My Strategy", executed=False)
for action in page.get("actions", []):
# Execute trade on your exchange here
api.update_strategy_action_status(notification_id=action.get("notificationId"), executed=True, strategy_name="My Strategy")
Tip: In the example script main.py, a DO_PATCH flag is used to prevent side effects during demos. In production, call update_strategy_action_status(..., executed=True) only after your exchange order succeeds.
For more information about the AlphaSquared API, consult the official API documentation.
This project is licensed under the MIT License. See the LICENSE file for more information.
This project is not affiliated with, maintained, or endorsed by AlphaSquared. Use this software at your own risk. Trading cryptocurrencies carries a risk of financial loss. The developers of this software are not responsible for any financial losses or damages incurred while using this software.
For any issues, questions, or assistance, please open an issue on the GitHub repository or contact AlphaSquared support at admin@alphasquared.io.
FAQs
The unofficial Python client for the AlphaSquared API
We found that alphasquared-py demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Season’s greetings from Socket, and here’s to a calm end of year: clean dependencies, boring pipelines, no surprises.

Research
/Security News
Impostor NuGet package Tracer.Fody.NLog typosquats Tracer.Fody and its author, using homoglyph tricks, and exfiltrates Stratis wallet JSON/passwords to a Russian IP address.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.