Skip to main content

The unofficial Python client for the AlphaSquared API

Project description

AlphaSquared Python Client

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.

Features

  • Easy-to-use Python wrapper for the AlphaSquared API
  • Supports authentication using API tokens
  • Implements rate limiting to comply with API usage rules
  • Provides methods to retrieve asset information, strategy values, and hypothetical data
  • Includes error handling and logging functionality
  • Fetch comprehensive asset data (price, risk, market cap, etc.)
  • Get custom strategy values
  • Built-in caching to reduce API calls
  • Automatic rate limiting to comply with API rules
  • Configurable logging with debug mode for development

Installation

Install the package using pip:

pip install alphasquared-py

Authentication

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)

Usage

Retrieving Asset Information

btc_info = api.get_asset_info("BTC")
print(btc_info)

Getting Strategy Values

strategy_values = api.get_strategy_values("My Custom Strat")
print(strategy_values)

Fetching Hypothetical Data

eth_hypotheticals = api.get_hypotheticals("ETH")
print(eth_hypotheticals)

Fetching Comprehensive Asset Data

btc_comprehensive = api.get_comprehensive_asset_data("BTC")
print(btc_comprehensive)

Getting Strategy Action and Value for a Specific Risk Level

action, value = api.get_strategy_value_for_risk("My Custom Strat", 50)
print(f"Action: {action}, Value: {value}")

Getting Current Risk Level

current_risk = api.get_current_risk("BTC")
print(current_risk)

Getting Strategy Action and Value Based on 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}")

Error Handling

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"])

Rate Limiting

The client automatically handles rate limiting to ensure compliance with the API's usage rules (6 requests per minute).

Caching

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

Logging

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.

Documentation

For more information about the AlphaSquared API, consult the official API documentation.

License

This project is licensed under the MIT License. See the LICENSE file for more information.

Disclaimer

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.

Support

For any issues, questions, or assistance, please open an issue on the GitHub repository or contact AlphaSquared support at admin@alphasquared.io.

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

alphasquared_py-0.3.1.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

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

alphasquared_py-0.3.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file alphasquared_py-0.3.1.tar.gz.

File metadata

  • Download URL: alphasquared_py-0.3.1.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for alphasquared_py-0.3.1.tar.gz
Algorithm Hash digest
SHA256 bec9918c8099807e01ef25a2b42438acf64486b79b0ea90d16eef0c8bdfd636e
MD5 605dd9f82e35f9178b0c8167fa6653a2
BLAKE2b-256 6ef35c27f1a50b17736e94023406063a2767b5984ab22fccb6e88556a5a84c83

See more details on using hashes here.

File details

Details for the file alphasquared_py-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for alphasquared_py-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 833ce7550ea5d8847de7ba9f03cdaa9fc7e3aa26f5f6f959e922c255da5a4ee2
MD5 0d9fc329270c6d5a8089daa6cf5487d3
BLAKE2b-256 b5cadf20f839be93363444de0eba5aa726b9b0e7066464bb6f149e9800bd91a1

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